libexplain  1.4.D001
libexplain/buffer/rusage.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - a library of system-call-specific strerror replacements
00003  * Copyright (C) 2013 Peter Miller
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU Lesser General Public License as
00007  * published by the Free Software Foundation; either version 3 of the
00008  * License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public License
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #include <libexplain/ac/sys/resource.h>
00020 
00021 #include <libexplain/buffer/long.h>
00022 #include <libexplain/buffer/pointer.h>
00023 #include <libexplain/buffer/rusage.h>
00024 #include <libexplain/buffer/timeval.h>
00025 #include <libexplain/is_efault.h>
00026 
00027 
00028 void
00029 explain_buffer_rusage(explain_string_buffer_t *sb,
00030     const struct rusage *data)
00031 {
00032     if (explain_is_efault_pointer(data, sizeof(*data)))
00033     {
00034         explain_buffer_pointer(sb, data);
00035         return;
00036     }
00037 
00038     explain_string_buffer_puts(sb, "{ ru_utime = ");
00039     explain_buffer_timeval(sb, &data->ru_utime);
00040     explain_string_buffer_puts(sb, ", ru_stime = ");
00041     explain_buffer_timeval(sb, &data->ru_stime);
00042     if (data->ru_maxrss)
00043     {
00044         explain_string_buffer_puts(sb, ", ru_maxrss = ");
00045         explain_buffer_long(sb, data->ru_maxrss);
00046     }
00047     if (data->ru_ixrss)
00048     {
00049         explain_string_buffer_puts(sb, ", ru_ixrss = ");
00050         explain_buffer_long(sb, data->ru_ixrss);
00051     }
00052     if (data->ru_idrss)
00053     {
00054         explain_string_buffer_puts(sb, ", ru_idrss = ");
00055         explain_buffer_long(sb, data->ru_idrss);
00056     }
00057     if (data->ru_isrss)
00058     {
00059         explain_string_buffer_puts(sb, ", ru_isrss = ");
00060         explain_buffer_long(sb, data->ru_isrss);
00061     }
00062     if (data->ru_minflt)
00063     {
00064         explain_string_buffer_puts(sb, ", ru_minflt = ");
00065         explain_buffer_long(sb, data->ru_minflt);
00066     }
00067     if (data->ru_majflt)
00068     {
00069         explain_string_buffer_puts(sb, ", ru_majflt = ");
00070         explain_buffer_long(sb, data->ru_majflt);
00071     }
00072     if (data->ru_nswap)
00073     {
00074         explain_string_buffer_puts(sb, ", ru_nswap = ");
00075         explain_buffer_long(sb, data->ru_nswap);
00076     }
00077     if (data->ru_inblock)
00078     {
00079         explain_string_buffer_puts(sb, ", ru_inblock = ");
00080         explain_buffer_long(sb, data->ru_inblock);
00081     }
00082     if (data->ru_oublock)
00083     {
00084         explain_string_buffer_puts(sb, ", ru_oublock = ");
00085         explain_buffer_long(sb, data->ru_oublock);
00086     }
00087     if (data->ru_msgsnd)
00088     {
00089         explain_string_buffer_puts(sb, ", ru_msgsnd = ");
00090         explain_buffer_long(sb, data->ru_msgsnd);
00091     }
00092     if (data->ru_msgrcv)
00093     {
00094         explain_string_buffer_puts(sb, ", ru_msgrcv = ");
00095         explain_buffer_long(sb, data->ru_msgrcv);
00096     }
00097     if (data->ru_nsignals)
00098     {
00099         explain_string_buffer_puts(sb, ", ru_nsignals = ");
00100         explain_buffer_long(sb, data->ru_nsignals);
00101     }
00102     if (data->ru_nvcsw)
00103     {
00104         explain_string_buffer_puts(sb, ", ru_nvcsw = ");
00105         explain_buffer_long(sb, data->ru_nvcsw);
00106     }
00107     if (data->ru_nivcsw)
00108     {
00109         explain_string_buffer_puts(sb, ", ru_nivcsw = ");
00110         explain_buffer_long(sb, data->ru_nivcsw);
00111     }
00112     explain_string_buffer_puts(sb, " }");
00113 }
00114 
00115 
00116 /* vim: set ts=8 sw=4 et : */