added QSE_ALIGNOF().
This commit is contained in:
parent
df28fde9ef
commit
1f9de59543
@ -119,7 +119,7 @@
|
|||||||
#define QSE_SIZEOF(n) (sizeof(n))
|
#define QSE_SIZEOF(n) (sizeof(n))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The QSE_COUNTOF() macro gets the number elements in a array.
|
* The QSE_COUNTOF() macro returns the number elements in an array.
|
||||||
* The following code snippet should print 128.
|
* The following code snippet should print 128.
|
||||||
* @code
|
* @code
|
||||||
* int x[128];
|
* int x[128];
|
||||||
@ -129,16 +129,24 @@
|
|||||||
#define QSE_COUNTOF(n) (sizeof(n)/sizeof(n[0]))
|
#define QSE_COUNTOF(n) (sizeof(n)/sizeof(n[0]))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The QSE_OFFSETOF() macro get the offset of a fields from the beginning
|
* The QSE_OFFSETOF() macro returns the offset of a field from the beginning
|
||||||
* of a structure.
|
* of a structure.
|
||||||
*/
|
*/
|
||||||
#define QSE_OFFSETOF(type,member) ((qse_size_t)&((type*)0)->member)
|
#define QSE_OFFSETOF(type,member) \
|
||||||
|
((qse_size_t)&((type*)0)->member)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The QSE_ALIGNOF() macro returns the alignment size of a structure.
|
||||||
|
* Note that this macro may not work reliably depending on the type given.
|
||||||
|
*/
|
||||||
|
#define QSE_ALIGNOF(type) QSE_OFFSETOF(struct { qse_uint8_t d1; type d2 }, d2)
|
||||||
|
/*(sizeof(struct { qse_uint8_t d1; type d2 }) - sizeof(type))*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The QSE_TYPE_IS_SIGNED() macro determines if a type is signed.
|
* The QSE_TYPE_IS_SIGNED() macro determines if a type is signed.
|
||||||
* @code
|
* @code
|
||||||
* printf ("%d\n", QSE_TYPE_IS_SIGNED(int));
|
* printf ("%d\n", (int)QSE_TYPE_IS_SIGNED(int));
|
||||||
* printf ("%d\n", QSE_TYPE_IS_SIGNED(unsigned int));
|
* printf ("%d\n", (int)QSE_TYPE_IS_SIGNED(unsigned int));
|
||||||
* @endcode
|
* @endcode
|
||||||
*/
|
*/
|
||||||
#define QSE_TYPE_IS_SIGNED(type) (((type)0) > ((type)-1))
|
#define QSE_TYPE_IS_SIGNED(type) (((type)0) > ((type)-1))
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#pragma pack(1)
|
# pragma pack(1)
|
||||||
#elif defined(__HP_aCC) || defined(__HP_cc)
|
#elif defined(__HP_aCC) || defined(__HP_cc)
|
||||||
#pragma PACK 1
|
# pragma PACK 1
|
||||||
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
#pragma pack(push,1)
|
# pragma pack(push,1)
|
||||||
#elif defined(__DECC)
|
#elif defined(__DECC)
|
||||||
#pragma pack(push,1)
|
# pragma pack(push,1)
|
||||||
#else
|
#else
|
||||||
#pragma pack(1)
|
# pragma pack(1)
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#pragma pack(2)
|
# pragma pack(2)
|
||||||
#elif defined(__HP_aCC) || defined(__HP_cc)
|
#elif defined(__HP_aCC) || defined(__HP_cc)
|
||||||
#pragma PACK 2
|
# pragma PACK 2
|
||||||
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
#pragma pack(push,2)
|
# pragma pack(push,2)
|
||||||
#elif defined(__DECC)
|
#elif defined(__DECC)
|
||||||
#pragma pack(push,2)
|
# pragma pack(push,2)
|
||||||
#else
|
#else
|
||||||
#pragma pack(2)
|
# pragma pack(2)
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#pragma pack()
|
# pragma pack()
|
||||||
#elif defined(__HP_aCC) || defined(__HP_cc)
|
#elif defined(__HP_aCC) || defined(__HP_cc)
|
||||||
#pragma PACK
|
# pragma PACK
|
||||||
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
||||||
#pragma pack(pop)
|
# pragma pack(pop)
|
||||||
#elif defined(__DECC)
|
#elif defined(__DECC)
|
||||||
#pragma pack(pop)
|
# pragma pack(pop)
|
||||||
#else
|
#else
|
||||||
#pragma pack()
|
# pragma pack()
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||||
|
This file is part of QSE.
|
||||||
|
|
||||||
|
QSE is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
QSE is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <qse/cmn/alg.h>
|
#include <qse/cmn/alg.h>
|
||||||
|
|
||||||
/* Park-Miller "minimal standard" 31 bit
|
/* Park-Miller "minimal standard" 31 bit
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#include <qse/cmn/fio.h>
|
#include <qse/cmn/fio.h>
|
||||||
#include <qse/cmn/stdio.h>
|
#include <qse/cmn/stdio.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <locale.h>
|
|
||||||
|
|
||||||
#define R(f) \
|
#define R(f) \
|
||||||
do { \
|
do { \
|
||||||
@ -25,7 +23,7 @@ static int test1 (void)
|
|||||||
QSE_NULL,
|
QSE_NULL,
|
||||||
0,
|
0,
|
||||||
file,
|
file,
|
||||||
QSE_FIO_CREATE | QSE_FIO_EXCLUSIVE | QSE_FIO_TEMPORARY | QSE_FIO_READ | QSE_FIO_WRITE,
|
QSE_FIO_CREATE | QSE_FIO_EXCLUSIVE | QSE_FIO_TEMPORARY | QSE_FIO_READ | QSE_FIO_WRITE,
|
||||||
QSE_FIO_RUSR|QSE_FIO_WUSR|QSE_FIO_RGRP|QSE_FIO_ROTH
|
QSE_FIO_RUSR|QSE_FIO_WUSR|QSE_FIO_RGRP|QSE_FIO_ROTH
|
||||||
);
|
);
|
||||||
if (fio == QSE_NULL)
|
if (fio == QSE_NULL)
|
||||||
@ -81,13 +79,6 @@ static int test1 (void)
|
|||||||
|
|
||||||
int main ()
|
int main ()
|
||||||
{
|
{
|
||||||
setlocale (LC_ALL, "");
|
|
||||||
|
|
||||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
|
||||||
qse_printf (QSE_T("Set the environment LANG to a Unicode locale such as UTF-8 if you see the illegal XXXXX errors. If you see such errors in Unicode locales, this program might be buggy. It is normal to see such messages in non-Unicode locales as it uses Unicode data\n"));
|
|
||||||
qse_printf (QSE_T("--------------------------------------------------------------------------------\n"));
|
|
||||||
|
|
||||||
R (test1);
|
R (test1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,6 @@ oops:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int qse_main (int argc, qse_achar_t* argv[])
|
int qse_main (int argc, qse_achar_t* argv[])
|
||||||
{
|
{
|
||||||
return qse_runmain (argc, argv, sed_main);
|
return qse_runmain (argc, argv, sed_main);
|
||||||
|
Loading…
Reference in New Issue
Block a user