libc: Update headers with more comments
This commit is contained in:
parent
af452e2b2a
commit
13fce2c4b3
@ -18,7 +18,7 @@ extern "C"
|
|||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define assert(expr) (void)0
|
#define assert(expr) (void)0
|
||||||
#else
|
#else
|
||||||
#define assert(expr) (bool)(expr) || __assertion_failed(__FILE__, __LINE__, __FUNCTION__, #expr)
|
#define assert(expr) (bool)(expr) || __assertion_failed(__FILE__, __LINE__, __FUNCTION__, #expr) // Verify a condition.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,6 +4,7 @@
|
|||||||
#define __lc_noreturn __attribute__((noreturn))
|
#define __lc_noreturn __attribute__((noreturn))
|
||||||
#define __lc_align(n) __attribute__((aligned(n)))
|
#define __lc_align(n) __attribute__((aligned(n)))
|
||||||
#define __lc_deprecated(msg) __attribute__((deprecated(msg)))
|
#define __lc_deprecated(msg) __attribute__((deprecated(msg)))
|
||||||
|
#define __lc_is_deprecated __attribute__((deprecated))
|
||||||
#define __lc_unreachable __builtin_unreachable
|
#define __lc_unreachable __builtin_unreachable
|
||||||
#define __lc_used __attribute__((used))
|
#define __lc_used __attribute__((used))
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef _CTYPE_H
|
#ifndef _CTYPE_H
|
||||||
#define _CTYPE_H
|
#define _CTYPE_H
|
||||||
|
|
||||||
|
#include <bits/macros.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -51,6 +53,10 @@ extern "C"
|
|||||||
/* Returns the uppercase form of the specified character. */
|
/* Returns the uppercase form of the specified character. */
|
||||||
int toupper(int c);
|
int toupper(int c);
|
||||||
|
|
||||||
|
/* Returns the character c, truncated to fit in the ASCII character set. This function should not be used, as it
|
||||||
|
* will convert accented letters into random characters. */
|
||||||
|
__lc_is_deprecated int toascii(int c);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <luna/os-limits.h>
|
#include <luna/os-limits.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
/* An entry in a directory. */
|
||||||
struct dirent
|
struct dirent
|
||||||
{
|
{
|
||||||
ino_t d_ino;
|
ino_t d_ino;
|
||||||
@ -13,6 +14,7 @@ struct dirent
|
|||||||
char d_name[NAME_MAX];
|
char d_name[NAME_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* A stream representing a directory. */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int d_dirfd;
|
int d_dirfd;
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
|
|
||||||
#include <bits/seek.h>
|
#include <bits/seek.h>
|
||||||
|
|
||||||
#define FOPEN_MAX 32
|
#define FOPEN_MAX 32 // Maximum number of files that can be simultaneously opened with fopen().
|
||||||
#define BUFSIZ 32
|
#define BUFSIZ 32 // Standard buffer size.
|
||||||
#define FILENAME_MAX 1024 // Dummy value, we don't have a limit for filenames right now.
|
#define FILENAME_MAX 1024 // Dummy value, we don't have a limit for filenames right now.
|
||||||
|
|
||||||
|
/* A stream representing a file. */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int f_fd;
|
int f_fd;
|
||||||
@ -25,17 +26,18 @@ typedef struct
|
|||||||
extern FILE* stderr;
|
extern FILE* stderr;
|
||||||
extern FILE* stdout;
|
extern FILE* stdout;
|
||||||
extern FILE* stdin;
|
extern FILE* stdin;
|
||||||
#define stdin stdin
|
|
||||||
#define stdout stdout
|
|
||||||
#define stderr stderr
|
|
||||||
|
|
||||||
#define EOF -1
|
#define stdin stdin // The standard input stream.
|
||||||
|
#define stdout stdout // The standard output stream.
|
||||||
|
#define stderr stderr // The standard error stream.
|
||||||
|
|
||||||
#define _IONBF 0
|
#define EOF -1 // End of file.
|
||||||
#define _IOLBF 1
|
|
||||||
#define _IOFBF 2
|
|
||||||
|
|
||||||
typedef off_t fpos_t;
|
#define _IONBF 0 // Not buffered.
|
||||||
|
#define _IOLBF 1 // Line buffered.
|
||||||
|
#define _IOFBF 2 // Fully buffered.
|
||||||
|
|
||||||
|
typedef off_t fpos_t; // An offset into a file.
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -5,23 +5,26 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#define EXIT_SUCCESS 0
|
#define EXIT_SUCCESS 0 // Value to use when calling exit() to represent successful execution.
|
||||||
#define EXIT_FAILURE 1
|
#define EXIT_FAILURE 1 // Value to use when calling exit() to represent failed execution.
|
||||||
|
|
||||||
#define RAND_MAX INT_MAX
|
#define RAND_MAX INT_MAX // Maximum number returned by rand().
|
||||||
|
|
||||||
|
// Return type for an integer division.
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int quot;
|
int quot;
|
||||||
int rem;
|
int rem;
|
||||||
} div_t;
|
} div_t;
|
||||||
|
|
||||||
|
// Return type for a long integer division.
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
long quot;
|
long quot;
|
||||||
long rem;
|
long rem;
|
||||||
} ldiv_t;
|
} ldiv_t;
|
||||||
|
|
||||||
|
// Return type for a long integer division.
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
long long quot;
|
long long quot;
|
||||||
|
@ -19,4 +19,10 @@ typedef unsigned short mode_t;
|
|||||||
/* The type of a filesystem inode. */
|
/* The type of a filesystem inode. */
|
||||||
typedef unsigned long ino_t;
|
typedef unsigned long ino_t;
|
||||||
|
|
||||||
|
/* Value representing a time unit since the start of the current program. */
|
||||||
|
typedef long int clock_t;
|
||||||
|
|
||||||
|
/* Value representing time in seconds. */
|
||||||
|
typedef long int time_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -2,10 +2,9 @@
|
|||||||
#define _TIME_H
|
#define _TIME_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
typedef long int clock_t;
|
// Structure representing broken-down time.
|
||||||
typedef long int time_t;
|
|
||||||
|
|
||||||
struct tm
|
struct tm
|
||||||
{
|
{
|
||||||
int tm_sec;
|
int tm_sec;
|
||||||
@ -22,7 +21,7 @@ struct tm
|
|||||||
const char* tm_zone;
|
const char* tm_zone;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CLOCKS_PER_SEC 1000
|
#define CLOCKS_PER_SEC 1000 // Number of clock_t per second.
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -78,4 +78,9 @@ extern "C"
|
|||||||
if (islower(c)) return c & 0x5f;
|
if (islower(c)) return c & 0x5f;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int toascii(int c)
|
||||||
|
{
|
||||||
|
return c & 0x7f;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user