~ubuntu-branches/ubuntu/precise/openarena/precise

« back to all changes in this revision

Viewing changes to code/SDL12/include/SDL_endian.h

  • Committer: Bazaar Package Importer
  • Author(s): Ansgar Burchardt
  • Date: 2008-09-05 21:14:51 UTC
  • mfrom: (1.2.1 upstream) (2.1.5 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080905211451-243bmbl6l6gdav7l
* Remove non-free code/tools/lcc (Closes: #496346)
  + Remove hunk from patch 10_fix_build_and_binary_on_alpha
  + debian/rules: Add BUILD_GAME_QVM=0 to $(MAKE) call
    (thanks to Peter De Wachter)
* Remove code/libs containing binary libraries for Mac OS X and Win32
* debian/copyright: Explain which parts of upstream's sources were removed
* debian/rules: replace ${source:Upstream-Version} by 0.7.7
  because the variable also contains the `+dfsg1' part
* Add -fsigned-char to compiler options (Closes: #487970)
  (thanks to Peter De Wachter)
* Add myself to Uploaders
* debian/control: Remove article from beginning of short description,
  don't start short description with a capital letter
* debian/openarena.6: Escape minus signs
  + fixes lintian warnings: hyphen-used-as-minus-sign

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
    SDL - Simple DirectMedia Layer
3
 
    Copyright (C) 1997-2004 Sam Lantinga
 
3
    Copyright (C) 1997-2006 Sam Lantinga
4
4
 
5
5
    This library is free software; you can redistribute it and/or
6
 
    modify it under the terms of the GNU Library General Public
 
6
    modify it under the terms of the GNU Lesser General Public
7
7
    License as published by the Free Software Foundation; either
8
 
    version 2 of the License, or (at your option) any later version.
 
8
    version 2.1 of the License, or (at your option) any later version.
9
9
 
10
10
    This library is distributed in the hope that it will be useful,
11
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 
    Library General Public License for more details.
 
13
    Lesser General Public License for more details.
14
14
 
15
 
    You should have received a copy of the GNU Library General Public
16
 
    License along with this library; if not, write to the Free
17
 
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
    You should have received a copy of the GNU Lesser General Public
 
16
    License along with this library; if not, write to the Free Software
 
17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 
19
19
    Sam Lantinga
20
20
    slouken@libsdl.org
21
21
*/
22
22
 
23
 
#ifdef SAVE_RCSID
24
 
static char rcsid =
25
 
 "@(#) $Id: SDL_endian.h,v 1.15 2005/03/30 12:38:03 pmandin Exp $";
26
 
#endif
27
 
 
28
23
/* Functions for reading and writing endian-specific values */
29
24
 
30
25
#ifndef _SDL_endian_h
31
26
#define _SDL_endian_h
32
27
 
33
 
/* These functions read and write data of the specified endianness, 
34
 
   dynamically translating to the host machine endianness.
35
 
 
36
 
   e.g.: If you want to read a 16 bit value on big-endian machine from
37
 
         an open file containing little endian values, you would use:
38
 
                value = SDL_ReadLE16(rp);
39
 
         Note that the read/write functions use SDL_RWops pointers
40
 
         instead of FILE pointers.  This allows you to read and write
41
 
         endian values from large chunks of memory as well as files 
42
 
         and other data sources.
43
 
*/
44
 
 
45
 
#include <stdio.h>
46
 
 
47
 
#include "SDL_types.h"
48
 
#include "SDL_rwops.h"
49
 
#include "SDL_byteorder.h"
 
28
#include "SDL_stdinc.h"
 
29
 
 
30
/* The two types of endianness */
 
31
#define SDL_LIL_ENDIAN  1234
 
32
#define SDL_BIG_ENDIAN  4321
 
33
 
 
34
#ifndef SDL_BYTEORDER   /* Not defined in SDL_config.h? */
 
35
#if defined(__hppa__) || \
 
36
    defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
 
37
    (defined(__MIPS__) && defined(__MISPEB__)) || \
 
38
    defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
 
39
    defined(__sparc__)
 
40
#define SDL_BYTEORDER   SDL_BIG_ENDIAN
 
41
#else
 
42
#define SDL_BYTEORDER   SDL_LIL_ENDIAN
 
43
#endif
 
44
#endif /* !SDL_BYTEORDER */
 
45
 
50
46
 
51
47
#include "begin_code.h"
52
48
/* Set up for C function definitions, even when using C++ */
59
55
   static for compilers that do not support inline functions, this
60
56
   header should only be included in files that actually use them.
61
57
*/
62
 
#if defined(__GNUC__) && defined(__i386__)
 
58
#if defined(__GNUC__) && defined(__i386__) && \
 
59
   !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */)
63
60
static __inline__ Uint16 SDL_Swap16(Uint16 x)
64
61
{
65
62
        __asm__("xchgb %b0,%h0" : "=q" (x) :  "0" (x));
186
183
#define SDL_SwapBE64(X) (X)
187
184
#endif
188
185
 
189
 
/* Read an item of the specified endianness and return in native format */
190
 
extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src);
191
 
extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src);
192
 
extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src);
193
 
extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src);
194
 
extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src);
195
 
extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src);
196
 
 
197
 
/* Write an item of native format to the specified endianness */
198
 
extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value);
199
 
extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value);
200
 
extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value);
201
 
extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value);
202
 
extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value);
203
 
extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value);
204
 
 
205
 
 
206
186
/* Ends C function definitions when using C++ */
207
187
#ifdef __cplusplus
208
188
}