Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys Add an __alignof() macro.



details:   https://anonhg.NetBSD.org/src/rev/4ae36ae037e1
branches:  trunk
changeset: 782224:4ae36ae037e1
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Oct 21 22:35:52 2012 +0000

description:
Add an __alignof() macro.

diffstat:

 sys/sys/cdefs.h |  7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diffs (21 lines):

diff -r 759f0cdeef9a -r 4ae36ae037e1 sys/sys/cdefs.h
--- a/sys/sys/cdefs.h   Sun Oct 21 22:18:16 2012 +0000
+++ b/sys/sys/cdefs.h   Sun Oct 21 22:35:52 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cdefs.h,v 1.100 2012/08/24 05:47:51 dholland Exp $     */
+/*     $NetBSD: cdefs.h,v 1.101 2012/10/21 22:35:52 christos Exp $     */
 
 /*
  * Copyright (c) 1991, 1993
@@ -498,6 +498,11 @@
 #define        __link_set_entry(set, idx)      (__link_set_start(set)[idx])
 
 /*
+ * Return the natural alignment in bytes for the given type
+ */
+#define        __alignof(__t)  (sizeof(struct { char __x; __t __y; }) - sizeof(__t))
+
+/*
  * Return the number of elements in a statically-allocated array,
  * __x.
  */



Home | Main Index | Thread Index | Old Index