libfossil
fossil-config.h File Reference
#include "autoconfig.h"

Go to the source code of this file.

Macros

#define FSL_CONFIG_ENABLE_TIMER   1
 If true, the fsl_timer_xxx() family of functions might do something useful, otherwise they do not. More...
 
#define FSL_DOUBLE_T_PFMT   "f"
 Fossil's fsl_double_t-equivalent of FSL_INT_T_PFMT and friends. More...
 
#define FSL_EXPORT   extern
 
#define FSL_HAS_FIXED_INTEGERS   0
 
#define FSL_ID_T_PFMT   FSL_INT32_T_PFMT
 Fossil's fsl_id_t equivalent of C99's PRIi32 and friends. More...
 
#define FSL_ID_T_SFMT   FSL_INT32_T_SFMT
 Fossil's fsl_id_t equivalent of C99's SCNi32 and friends. More...
 
#define FSL_INT32_T_PFMT   "i"
 
#define FSL_INT32_T_SFMT   "i"
 
#define FSL_INT64_T_PFMT   "lli"
 
#define FSL_INT64_T_SFMT   "lli"
 
#define FSL_INT_T_PFMT   FSL_INT64_T_PFMT
 printf format specifier for fsl_int_t. More...
 
#define FSL_INT_T_SFMT   FSL_INT64_T_SFMT
 scanf format specifier for fsl_int_t. More...
 
#define FSL_JULIAN_T_PFMT   ".17g"
 An output format specifier for Julian-format doubles. More...
 
#define FSL_SIZE_T_PFMT   FSL_UINT_T_PFMT
 Fossil's fsl_size_t equivalent of C99's PRIu32 and friends. More...
 
#define FSL_SIZE_T_SFMT   FSL_UINT_T_SFMT
 Fossil's fsl_int_t equivalent of C99's SCNu32 and friends. More...
 
#define FSL_TIME_T_PFMT   FSL_INT64_T_PFMT
 Fossil's fsl_time_t equivalent of C99's PRIi32 and friends. More...
 
#define FSL_TIME_T_SFMT   FSL_INT64_T_SFMT
 Fossil's fsl_time_t equivalent of C99's SCNi32 and friends. More...
 
#define FSL_UINT32_T_PFMT   "u"
 
#define FSL_UINT32_T_SFMT   "u"
 
#define FSL_UINT64_T_PFMT   "llu"
 
#define FSL_UINT64_T_SFMT   "llu"
 
#define FSL_UINT_T_PFMT   FSL_UINT64_T_PFMT
 printf format specifier for fsl_uint_t. More...
 
#define FSL_UINT_T_SFMT   FSL_UINT64_T_SFMT
 scanf format specifier for fsl_uint_t. More...
 

Typedefs

typedef double fsl_double_t
 fsl_double_t is the double type used by the library. More...
 
typedef fsl_int32_t fsl_id_t
 fsl_id_t is a signed integer type used to store database record IDs. More...
 
typedef short fsl_int16_t
 A workaround for late-2015 gcc versions adding __func__ warnings to -pedantic mode. More...
 
typedef int fsl_int32_t
 
typedef long long int fsl_int64_t
 
typedef fsl_int64_t fsl_int_t
 fsl_int_t is a signed integer type used to denote "relative" ranges and lengths, or to tell a routine that it should try to figure out the length of some byte array itself (e.g. More...
 
typedef fsl_uint_t fsl_size_t
 fsl_size_t is an unsigned integer type used to denote absolute ranges and lengths. More...
 
typedef fsl_int64_t fsl_time_t
 The type used to represent type values. More...
 
typedef unsigned short fsl_uint16_t
 
typedef unsigned int fsl_uint32_t
 
typedef unsigned long long int fsl_uint64_t
 
typedef fsl_uint64_t fsl_uint_t
 The unsigned counterpart of fsl_int_t. More...
 

Macro Definition Documentation

#define FSL_CONFIG_ENABLE_TIMER   1

If true, the fsl_timer_xxx() family of functions might do something useful, otherwise they do not.

Definition at line 350 of file fossil-config.h.

#define FSL_DOUBLE_T_PFMT   "f"

Fossil's fsl_double_t-equivalent of FSL_INT_T_PFMT and friends.

Definition at line 210 of file fossil-config.h.

#define FSL_EXPORT   extern

Definition at line 19 of file fossil-config.h.

#define FSL_HAS_FIXED_INTEGERS   0

Definition at line 32 of file fossil-config.h.

#define FSL_ID_T_PFMT   FSL_INT32_T_PFMT

Fossil's fsl_id_t equivalent of C99's PRIi32 and friends.

ACHTUNG: see FSL_SIZE_T_PFMT for important details.

Definition at line 315 of file fossil-config.h.

#define FSL_ID_T_SFMT   FSL_INT32_T_SFMT

Fossil's fsl_id_t equivalent of C99's SCNi32 and friends.

Definition at line 321 of file fossil-config.h.

#define FSL_INT32_T_PFMT   "i"

Definition at line 84 of file fossil-config.h.

#define FSL_INT32_T_SFMT   "i"

Definition at line 85 of file fossil-config.h.

#define FSL_INT64_T_PFMT   "lli"

Definition at line 97 of file fossil-config.h.

#define FSL_INT64_T_SFMT   "lli"

Definition at line 98 of file fossil-config.h.

#define FSL_INT_T_PFMT   FSL_INT64_T_PFMT

printf format specifier for fsl_int_t.

Fossil's fsl_int_t equivalent of C99's PRIi32 and friends.

#define FSL_INT_T_SFMT   FSL_INT64_T_SFMT

scanf format specifier for fsl_int_t.

Fossil's fsl_int_t equivalent of C99's SCNi32 and friends.

#define FSL_JULIAN_T_PFMT   ".17g"

An output format specifier for Julian-format doubles.

Definition at line 216 of file fossil-config.h.

#define FSL_SIZE_T_PFMT   FSL_UINT_T_PFMT

Fossil's fsl_size_t equivalent of C99's PRIu32 and friends.

ACHTUNG: when passing arguments of this type of fsl_appendf(), or any function which uses it for formatting purposes, it is very important if if you pass _literal integers_ OR enum values, that they be cast to fsl_size_t, or the va_list handling might extract the wrong number of bytes from the argument list, leading to really weird side-effects via what is effectively memory corruption.

That warning applies primarily to the following typedefs and their format specifiers: fsl_size_t, fsl_int_t, fsl_uint_t, fsl_id_t.

The warning does not apply to strongly-typed arguments, e.g. variables of the proper type, so long as the format specifier string matches the argument type.

For example:

1 fsl_size_t sz = 3;
2 fsl_fprintf( stdout, "%"FSL_SIZE_T_PFMT" %"FSL_SIZE_T_PFMT\n",
3  sz, // OK!
4  3 // BAD! See below...
5  );

The "fix" is to cast the literal 3 to a fsl_size_t resp. the type appropriate for the format specifier. That ensures that there is no (or much less ;) confusion when va_arg() extracts arguments from the variadic array.

Reminders to self:

1 int i = 0;
2 f_out(("#%d: %"FSL_ID_T_PFMT" %"FSL_ID_T_PFMT" %"FSL_ID_T_PFMT"\n",
3  ++i, 1, 2, 3));
4 f_out(("#%d: %"FSL_SIZE_T_PFMT" %"FSL_ID_T_PFMT" %"FSL_SIZE_T_PFMT"\n",
5  ++i, (fsl_size_t)1, (fsl_id_t)2, (fsl_size_t)3));
6 // This one is the (generally) problematic case:
7 f_out(("#%d: %"FSL_SIZE_T_PFMT" %"FSL_ID_T_PFMT" %"FSL_SIZE_T_PFMT"\n",
8  ++i, 1, 2, 3));

The above was Tested with gcc, clang, tcc on a 32-bit linux platform (it has not been problematic on 64-bit builds!). The above problem was reproduced on all compiler combinations i tried. Current code (20130824) seems to be behaving well as long as callers always cast to help variadic arg handling DTRT.

Definition at line 283 of file fossil-config.h.

#define FSL_SIZE_T_SFMT   FSL_UINT_T_SFMT

Fossil's fsl_int_t equivalent of C99's SCNu32 and friends.

Definition at line 289 of file fossil-config.h.

#define FSL_TIME_T_PFMT   FSL_INT64_T_PFMT

Fossil's fsl_time_t equivalent of C99's PRIi32 and friends.

Definition at line 338 of file fossil-config.h.

#define FSL_TIME_T_SFMT   FSL_INT64_T_SFMT

Fossil's fsl_time_t equivalent of C99's SCNi32 and friends.

Definition at line 344 of file fossil-config.h.

#define FSL_UINT32_T_PFMT   "u"

Definition at line 86 of file fossil-config.h.

#define FSL_UINT32_T_SFMT   "u"

Definition at line 87 of file fossil-config.h.

#define FSL_UINT64_T_PFMT   "llu"

Definition at line 99 of file fossil-config.h.

#define FSL_UINT64_T_SFMT   "llu"

Definition at line 100 of file fossil-config.h.

#define FSL_UINT_T_PFMT   FSL_UINT64_T_PFMT

printf format specifier for fsl_uint_t.

Fossil's fsl_uint_t equivalent of C99's PRIu32 and friends.

#define FSL_UINT_T_SFMT   FSL_UINT64_T_SFMT

scanf format specifier for fsl_uint_t.

Fossil's fsl_uint_t equivalent of C99's SCNu32 and friends.

Typedef Documentation

typedef double fsl_double_t

fsl_double_t is the double type used by the library.

It is currently hard-coded to double but the API allows for it to eventually be used with long double, or potentially even with integers as a substitute (but note that Fossil generally stores times in Julian Date format, which requires double precision).

Definition at line 204 of file fossil-config.h.

fsl_id_t is a signed integer type used to store database record IDs.

It is provided primarily for documentation/readability purposes, to avoid confusion with the widely varying integer semantics used by various APIs.

This type "could" be 32-bit (instead of 64) because the oldest/largest Fossil repo (the TCL tree, with 15 years of history) currently (August 2013) has only 131k RIDs. HOWEVER, changing this type can have side-effects vis-a-vis va_arg() deep in the fsl_appendf() implementation if FSL_ID_T_PFMT is not 100% correct for this typedef. After changing this, _make sure_ to do a full clean rebuild and test thoroughly because changing a sizeof can produce weird side-effects (effectively memory corruption) on unclean rebuilds.

Definition at line 307 of file fossil-config.h.

typedef short fsl_int16_t

A workaround for late-2015 gcc versions adding __func__ warnings to -pedantic mode.

Definition at line 79 of file fossil-config.h.

typedef int fsl_int32_t

Definition at line 81 of file fossil-config.h.

typedef long long int fsl_int64_t

Definition at line 94 of file fossil-config.h.

some_int_type fsl_int_t

fsl_int_t is a signed integer type used to denote "relative" ranges and lengths, or to tell a routine that it should try to figure out the length of some byte array itself (e.g.

by using fsl_strlen() on it). It is provided primarily for documentation/readability purposes, to avoid confusion with the widely varying integer semantics used by various APIs. This type is never used as a return type for functions which use "error code semantics." Those always use an unadorned integer type or some API-specific enum type.

The library typedefs this to a 64-bit type if possible, else a 32-bit type.

Definition at line 155 of file fossil-config.h.

fsl_size_t is an unsigned integer type used to denote absolute ranges and lengths.

It is provided primarily for documentation/readability purposes, to avoid confusion with the widely varying integer semantics used by various APIs. While a 32-bit type is legal, a 64-bit type is required for "unusually large" repos.

Definition at line 227 of file fossil-config.h.

The type used to represent type values.

Unless noted otherwise, the general convention is Unix Epoch. That said, Fossil internally uses Julian Date for times, so this typedef is clearly the result of over-specification/over-thinking the problem. THAT said, application-level code more commonly works with Unix timestamps, so... here it is. Over-specified, perhaps, but not 100% unjustifiable.

Definition at line 332 of file fossil-config.h.

typedef unsigned short fsl_uint16_t

Definition at line 80 of file fossil-config.h.

typedef unsigned int fsl_uint32_t

Definition at line 82 of file fossil-config.h.

typedef unsigned long long int fsl_uint64_t

Definition at line 95 of file fossil-config.h.

The unsigned counterpart of fsl_int_t.

Definition at line 159 of file fossil-config.h.