MentOS  0.8.0
The Mentoring Operating System
Macros | Typedefs
stddef.h File Reference

Define basic data types. More...

Go to the source code of this file.

Macros

#define NULL   ((void *)0)
 Define NULL.
 
#define EOF   (-1)
 Define End-Of-File.
 
#define BUFSIZ   512
 Define the size of a buffer.
 
#define offsetof(type, member)    ((size_t) & (((type *)0)->member))
 
#define container_of(ptr, type, member)    ((type *)((char *)(1 ? (ptr) : &((type *)0)->member) - offsetof(type, member)))
 Retrieve an enclosing structure from a pointer to a nested element.
 
#define alignof(type)
 Returns the alignment, in bytes, of the specified type. More...
 
#define count_of(x)   ((sizeof(x) / sizeof((x)[0])) / ((size_t)(!(sizeof(x) % sizeof((x)[0])))))
 Counts the number of elements of an array.
 
#define swap(a, b)
 Swaps two values. More...
 

Typedefs

typedef long signed int ptrdiff_t
 Is the signed integer type of the result of subtracting two pointers.
 
typedef unsigned char byte_t
 Define the byte type.
 
typedef unsigned long size_t
 Define the generic size type.
 
typedef long ssize_t
 Define the generic signed size type.
 
typedef unsigned int ino_t
 Define the type of an inode.
 
typedef unsigned int dev_t
 Used for device IDs.
 
typedef int uid_t
 The type of user-id.
 
typedef int gid_t
 The type of group-id.
 
typedef long int off_t
 The type of offset.
 
typedef unsigned int mode_t
 The type of mode.
 
typedef unsigned int pgprot_t
 This data-type is used to set protection bits of pages.
 

Detailed Description

Define basic data types.

Macro Definition Documentation

◆ alignof

#define alignof (   type)
Value:
struct { char c; type member; }, member)
#define offsetof(type, member)
Definition: stddef.h:56

Returns the alignment, in bytes, of the specified type.

◆ offsetof

#define offsetof (   type,
  member 
)     ((size_t) & (((type *)0)->member))

It evaluates to the offset (in bytes) of a given member within a struct or union type, an expression of type size_t.

◆ swap

#define swap (   a,
 
)
Value:
do { \
typeof(a) temp = (a); \
(a) = (b); \
(b) = temp; \
} while (0)

Swaps two values.

do { ... } while (0) allows to place multistatement operations, for instance, inside the following if stantement: if (condition) swap(var1, var2) which otherwise would be wrong.