Adjust sourcize.c to use _snprintf if using MSVC.
[SquirrelJME.git] / nanocoat / src / allocSizeOf.c
blob07b2cc6ee7fba18aa8c170f6ce2d1aad82aaa0d7
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 #include "sjme/nvm/rom.h"
11 #include "sjme/nvm/boot.h"
12 #include "sjme/nvm/allocSizeOf.h"
14 sjme_errorCode sjme_alloc_sizeOf(
15 sjme_alloc_sizeOfId id, sjme_jint count,
16 sjme_jint* outSize)
18 if (outSize == NULL)
19 return SJME_ERROR_NULL_ARGUMENTS;
21 if (id <= SJME_ALLOC_SIZEOF_UNKNOWN || id >= SJME_NUM_ALLOC_TYPE_SIZEOF)
22 return SJME_ERROR_INVALID_ARGUMENT;
24 /* Which type? */
25 switch (id)
27 case SJME_ALLOC_SIZEOF_ROM_SUITE_FUNCTIONS:
28 *outSize = sizeof(sjme_rom_suiteFunctions);
29 break;
31 case SJME_ALLOC_SIZEOF_RESERVED_POOL:
32 *outSize = 64 * 1024;
33 break;
35 case SJME_ALLOC_SIZEOF_NVM_BOOT_PARAM:
36 *outSize = sizeof(sjme_nvm_bootParam);
37 break;
39 case SJME_ALLOC_SIZEOF_POINTER:
40 *outSize = sizeof(sjme_pointer);
41 break;
43 #if defined(SJME_CONFIG_HAS_LITTLE_ENDIAN)
44 case SJME_ALLOC_SIZEOF_IS_LITTLE_ENDIAN:
45 *outSize = 1;
46 break;
48 case SJME_ALLOC_SIZEOF_IS_BIG_ENDIAN:
49 *outSize = 0;
50 break;
51 #elif defined(SJME_CONFIG_HAS_BIG_ENDIAN)
52 case SJME_ALLOC_SIZEOF_IS_LITTLE_ENDIAN:
53 *outSize = 0;
54 break;
56 case SJME_ALLOC_SIZEOF_IS_BIG_ENDIAN:
57 *outSize = 1;
58 break;
59 #endif
61 default:
62 return SJME_ERROR_INVALID_ARGUMENT;
65 /* Success! */
66 return SJME_ERROR_NONE;