| 1 | /* hostinfo.c |
| 2 | Copyright (C) 1992, 1993 Free Software Foundation, Inc. |
| 3 | |
| 4 | This file is part of Z8KSIM |
| 5 | |
| 6 | GNU CC is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2, or (at your option) |
| 9 | any later version. |
| 10 | |
| 11 | GNU CC is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with GNU CC; see the file COPYING. If not, write to |
| 18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 19 | |
| 20 | |
| 21 | /* This prog writes a header file with some host info in it */ |
| 22 | |
| 23 | union { |
| 24 | int as_int; |
| 25 | char as_char[4]; |
| 26 | } u; |
| 27 | |
| 28 | |
| 29 | int |
| 30 | main() |
| 31 | { |
| 32 | u.as_int = 0x01020304; |
| 33 | if (u.as_char[0] == 0x01) |
| 34 | { |
| 35 | printf("#define BIG_ENDIAN_HOST\n"); |
| 36 | } |
| 37 | else if (u.as_char[0] == 0x04) |
| 38 | { |
| 39 | printf("#define LITTLE_ENDIAN_HOST\n"); |
| 40 | } |
| 41 | |
| 42 | return 0; |
| 43 | |
| 44 | } |