summaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index d29cacf372..27489e568a 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -15,6 +15,8 @@
/* This is required on rh7 to make strptime not complain.
* We also need it to make memmem get defined (where available)
*/
+/* XXXX023 We should just use AC_USE_SYSTEM_EXTENSIONS in our autoconf,
+ * and get this (and other important stuff!) automatically */
#define _GNU_SOURCE
#include "compat.h"
@@ -660,7 +662,9 @@ touch_file(const char *fname)
/** Represents a lockfile on which we hold the lock. */
struct tor_lockfile_t {
+ /** Name of the file */
char *filename;
+ /** File descriptor used to hold the file open */
int fd;
};
@@ -766,7 +770,8 @@ tor_lockfile_unlock(tor_lockfile_t *lockfile)
tor_free(lockfile);
}
-/* Some old versions of Unix didn't define constants for these values,
+/** @{ */
+/** Some old versions of Unix didn't define constants for these values,
* and instead expect you to say 0, 1, or 2. */
#ifndef SEEK_CUR
#define SEEK_CUR 1
@@ -774,6 +779,7 @@ tor_lockfile_unlock(tor_lockfile_t *lockfile)
#ifndef SEEK_END
#define SEEK_END 2
#endif
+/** @} */
/** Return the position of <b>fd</b> with respect to the start of the file. */
off_t
@@ -813,6 +819,7 @@ static int n_sockets_open = 0;
/** Mutex to protect open_sockets, max_socket, and n_sockets_open. */
static tor_mutex_t *socket_accounting_mutex = NULL;
+/** Helper: acquire the socket accounting lock. */
static INLINE void
socket_accounting_lock(void)
{
@@ -821,6 +828,7 @@ socket_accounting_lock(void)
tor_mutex_acquire(socket_accounting_mutex);
}
+/** Helper: release the socket accounting lock. */
static INLINE void
socket_accounting_unlock(void)
{
@@ -879,6 +887,7 @@ tor_close_socket(int s)
return r;
}
+/** @{ */
#ifdef DEBUG_SOCKET_COUNTING
/** Helper: if DEBUG_SOCKET_COUNTING is enabled, remember that <b>s</b> is
* now an open socket. */
@@ -903,6 +912,7 @@ mark_socket_open(int s)
#else
#define mark_socket_open(s) STMT_NIL
#endif
+/** @} */
/** As socket(), but counts the number of open sockets. */
int
@@ -1090,6 +1100,8 @@ tor_socketpair(int family, int type, int protocol, int fd[2])
#endif
}
+/** Number of extra file descriptors to keep in reserve beyond those that we
+ * tell Tor it's allowed to use. */
#define ULIMIT_BUFFER 32 /* keep 32 extra fd's beyond _ConnLimit */
/** Learn the maximum allowed number of file descriptors. (Some systems
@@ -1202,6 +1214,7 @@ set_max_file_descriptors(rlim_t limit, int *max_out)
static int
log_credential_status(void)
{
+/** Log level to use when describing non-error UID/GID status. */
#define CREDENTIAL_LOG_LEVEL LOG_INFO
/* Real, effective and saved UIDs */
uid_t ruid, euid, suid;
@@ -1983,6 +1996,12 @@ tor_gettimeofday(struct timeval *timeval)
#define TIME_FNS_NEED_LOCKS
#endif
+/** @{ */
+/** As localtime_r, but defined for platforms that don't have it:
+ *
+ * Convert *<b>timep</b> to a struct tm in local time, and store the value in
+ * *<b>result</b>. Return the result on success, or NULL on failure.
+ */
#ifndef HAVE_LOCALTIME_R
#ifdef TIME_FNS_NEED_LOCKS
struct tm *
@@ -2010,7 +2029,14 @@ tor_localtime_r(const time_t *timep, struct tm *result)
}
#endif
#endif
+/** @} */
+/** @{ */
+/** As gmtimee_r, but defined for platforms that don't have it:
+ *
+ * Convert *<b>timep</b> to a struct tm in UTC, and store the value in
+ * *<b>result</b>. Return the result on success, or NULL on failure.
+ */
#ifndef HAVE_GMTIME_R
#ifdef TIME_FNS_NEED_LOCKS
struct tm *
@@ -2038,6 +2064,7 @@ tor_gmtime_r(const time_t *timep, struct tm *result)
}
#endif
#endif
+/** @} */
#if defined(USE_WIN32_THREADS)
void