explain_gettimeofday(3)
π NAME π
okay so bestie, this is explain_gettimeofday β she's the one who explains all the errors that gettimeofday(2) throws at you. like, the whole why behind the β¨vibeβ¨ of your failure. from the Library Functions Manual, and she's giving very much "let me translate this cryptic errno for you" energy. π
β¨ SYNOPSIS β¨
#include <libexplain/gettimeofday.h>
const char *explain_gettimeofday(struct timeval *tv, struct timezone
*tz);
const char *explain_errno_gettimeofday(int errnum, struct timeval *tv,
struct timezone *tz);
void explain_message_gettimeofday(char *message, int message_size,
struct timeval *tv, struct timezone *tz);
void explain_message_errno_gettimeofday(char *message, int message_size,
int errnum, struct timeval *tv, struct timezone *tz);
πΈ DESCRIPTION πΈ
so these functions? they're your little translators. they hand you explanations for errors that the gettimeofday(2) system call returns. no more squinting at a bare errno wondering what went wrong π
π¦ explain_gettimeofday
const char *explain_gettimeofday(struct timeval *tv, struct timezone
*tz);
the explain_gettimeofday function is here to give you an explanation of an error returned by the gettimeofday(2) system call. the least you're getting is the value of strerror(errno), but honestly? usually she does so much better and tells you the underlying cause with actual detail. main character behavior, fr fr. π
the errno global variable is the one used to obtain the error value that gets decoded. iykyk.
this function is meant to be used in a fashion similar to the following example:
if (gettimeofday(tv, tz) < 0)
{
fprintf(stderr, "%s\n", explain_gettimeofday(tv, tz));
exit(EXIT_FAILURE);
}
tvβ the originaltv, exactly as passed to thegettimeofday(2)system call. no edits, no notes, just as it was. πtzβ the originaltz, exactly as passed to thegettimeofday(2)system call. same deal.
Returns: the message explaining the error. β this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function that shares this buffer, including other threads. so like... don't get attached to it.
Note: this function is not thread safe, because it shares a return buffer across all threads, and so do many other functions in this library. be careful out there bestie π
π§ explain_errno_gettimeofday
const char *explain_errno_gettimeofday(int errnum, struct timeval *tv,
struct timezone *tz);
the explain_errno_gettimeofday function is used to obtain an explanation of an error returned by the gettimeofday(2) system call. the least the message will contain is the value of strerror(errnum), but usually it will do much better, and indicate the underlying cause in more detail. β¨
this function is intended to be used in a fashion similar to the following example:
if (gettimeofday(tv, tz) < 0)
{
int err = errno;
fprintf(stderr, "%s\n", explain_errno_gettimeofday(err, tv, tz));
exit(EXIT_FAILURE);
}
errnumβ the error value to be decoded, usually grabbed from theerrnoglobal variable right before this function is called. this is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value oferrno. so snag it early, okay? πtvβ the originaltv, exactly as passed to thegettimeofday(2)system call.tzβ the originaltz, exactly as passed to thegettimeofday(2)system call.
Returns: the message explaining the error. this message buffer is shared by all libexplain functions which do not supply a buffer in their argument list. this will be overwritten by the next call to any libexplain function which shares this buffer, including other threads.
Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library.
π explain_message_gettimeofday
void explain_message_gettimeofday(char *message, int message_size,
struct timeval *tv, struct timezone *tz);
the explain_message_gettimeofday function may be used to obtain an explanation of an error returned by the gettimeofday(2) system call. the least the message will contain is the value of strerror(errno), but usually it will do much better, and indicate the underlying cause in more detail. π
the errno global variable will be used to obtain the error value to be decoded.
this function is intended to be used in a fashion similar to the following example:
if (gettimeofday(tv, tz) < 0)
{
char message[3000];
explain_message_gettimeofday(message, sizeof(message), tv, tz);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
messageβ the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe. slay πmessage_sizeβ the size in bytes of the location in which to store the returned message.tvβ the originaltv, exactly as passed to thegettimeofday(2)system call.tzβ the originaltz, exactly as passed to thegettimeofday(2)system call.
π explain_message_errno_gettimeofday
void explain_message_errno_gettimeofday(char *message, int message_size,
int errnum, struct timeval *tv, struct timezone *tz);
the explain_message_errno_gettimeofday function may be used to obtain an explanation of an error returned by the gettimeofday(2) system call. the least the message will contain is the value of strerror(errnum), but usually it will do much better, and indicate the underlying cause in more detail. π«Ά
this function is intended to be used in a fashion similar to the following example:
if (gettimeofday(tv, tz) < 0)
{
int err = errno;
char message[3000];
explain_message_errno_gettimeofday(message, sizeof(message), err,
tv, tz);
fprintf(stderr, "%s\n", message);
exit(EXIT_FAILURE);
}
messageβ the location in which to store the returned message. if a suitable message return buffer is supplied, this function is thread safe. πmessage_sizeβ the size in bytes of the location in which to store the returned message.errnumβ the error value to be decoded, usually obtained from theerrnoglobal variable just before this function is called. this is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value oferrno. (yes, again. it really do be like that. π)tvβ the originaltv, exactly as passed to thegettimeofday(2)system call.tzβ the originaltz, exactly as passed to thegettimeofday(2)system call.
π SEE ALSO π
gettimeofday(2)β get time β°explain_gettimeofday_or_die(3)β get time and report errors π
π COPYRIGHT π
- libexplain version 1.4
- Copyright (C) 2008 Peter Miller
okay that's the whole page bestie, you ate that π stay iconic, go explain some errors, and remember β errno waits for no one β¨
~ this has been explain_gettimeofday(3) from the Library Functions Manual, served fresh πΈ ~
π¦ where this page comes from
- debian bookworm: libexplain-dev 1.4.D001-12+b1 Β· LGPL-3.0-or-later
- debian trixie: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- ubuntu jammy: libexplain-dev 1.4.D001-12 Β· LGPL-3.0-or-later
- ubuntu noble: libexplain-dev 1.4.D001-13 Β· LGPL-3.0-or-later
- ubuntu resolute: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- Copyright (C) 2008, 2009, 2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms