X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2Fendian.c;fp=sources%2Fendian.c;h=1e71896708073f72b278c81eca8988eff26bde9b;hp=0000000000000000000000000000000000000000;hb=13e1dfef7b970db44781986970292e62ad7c7c58;hpb=be0b7b2add1b886196ad5e0847657f85025adfbf diff --git a/sources/endian.c b/sources/endian.c new file mode 100644 index 0000000..1e71896 --- /dev/null +++ b/sources/endian.c @@ -0,0 +1,50 @@ +/* endian.c + * + * Copyright (C) 2003 Simone Piccardi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/*************************************************************** + * + * routine endian: routine to detect endianess + * + * Author: S. Piccardi + * May. 2003 + * + * $Id: endian.c,v 1.1 2003/06/01 21:41:28 piccardi Exp $ + * + ***************************************************************/ +#include + +int main(int argc, char *argv[]) +{ +/* + * Variables definition + */ + int i, val; + char buf[sizeof(int)]; + char * char_ptr; + int * int_ptr; + + val = 0xABCDEF01; /* endianess magic number */ + int_ptr = (int *) buf; + *int_ptr = val; + char_ptr = (char *) &val; + for (i=0; i