pointer.h

Mon, 20 Apr 2020 10:14:32 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Mon, 20 Apr 2020 10:14:32 -0500
changeset 119
87e3bb5086e8
parent 89
17a16ed84bbf
permissions
-rw-r--r--

Convert README to markdown

89
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
1 /*
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
2 * libtu/pointer.h
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
3 *
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
4 * Copyright (c) Tuomo Valkonen 2005.
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
5 *
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
6 * You may distribute and modify this library under the terms of either
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
7 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
8 */
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
9
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
10 #ifndef LIBTU_POINTER_H
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
11 #define LIBTU_POINTER_H
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
12
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
13 #define FIELD_OFFSET(T, F) ((long)((char*)&((T*)0)->F))
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
14 #define FIELD_TO_STRUCT(T, F, A) ((T*)(((char*)A)-FIELD_OFFSET(T, F)))
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
15
17a16ed84bbf Added struct field address macros.
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
16 #endif /* LIBTU_POINTER_H */

mercurial