mirror of https://github.com/fadden/nulib2.git
Minor Mac fixes
Eliminated the two inline functions. Support for function inlining in plain C is a bit uneven. The CRC calculation is now a macro, and the thread get-by-index is a plain function.
This commit is contained in:
parent
c6c7133d43
commit
1286c3518e
|
@ -1,3 +1,6 @@
|
|||
2015/01/02 fadden
|
||||
- Distinguish Unicode and Mac OS Roman strings.
|
||||
|
||||
2014/12/22 fadden
|
||||
- Source code cleanup.
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
* Compute 16-bit CRCs. Depending on the hardware, the table version
|
||||
* might be slower than the loop computation.
|
||||
*/
|
||||
#define COMPILE_CRC16_C 1
|
||||
#include "NufxLibPriv.h"
|
||||
|
||||
#define CRC_TAB
|
||||
|
|
|
@ -48,7 +48,6 @@ static NuError Nu_PartiallyValidateNuArchive(const NuArchive* pArchive)
|
|||
if (pArchive == NULL)
|
||||
return kNuErrInvalidArg;
|
||||
|
||||
pArchive = pArchive;
|
||||
if (pArchive->structMagic != kNuArchiveStructMagic)
|
||||
return kNuErrBadStruct;
|
||||
|
||||
|
|
|
@ -563,20 +563,15 @@ NuError Nu_CopyPresizedToArchive(NuArchive* pArchive,
|
|||
/* Crc16.c */
|
||||
extern const uint16_t gNuCrc16Table[256];
|
||||
uint16_t Nu_CalcCRC16(uint16_t seed, const uint8_t* ptr, int count);
|
||||
#ifdef COMPILE_CRC16_C /* just doing "static inline" warns def-but-not-used */
|
||||
#define CRC_INLINE /**/
|
||||
#else
|
||||
#define CRC_INLINE extern inline
|
||||
#endif
|
||||
#if defined(inline) && !defined(COMPILE_CRC16_C) /* somebody ovrd inline def? */
|
||||
uint16_t Nu_UpdateCRC16(uint8_t val, uint16_t crc);
|
||||
#else
|
||||
CRC_INLINE uint16_t
|
||||
Nu_UpdateCRC16(uint8_t val, uint16_t crc)
|
||||
{
|
||||
return (gNuCrc16Table[((crc >> 8) & 0xFF) ^ val] ^ (crc << 8)) & 0xFFFF;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Update the CRC-16.
|
||||
*
|
||||
* _val (uint8_t) is the byte to add to the CRC. It's evaluated once.
|
||||
* _crc (uint16_t) is the previous CRC. It's evaluated twice.
|
||||
* Returns the updated CRC as a uint16_t.
|
||||
*/
|
||||
#define Nu_UpdateCRC16(_val, _crc) \
|
||||
(gNuCrc16Table[(((_crc) >> 8) & 0xff) ^ (_val)] ^ ((_crc) << 8))
|
||||
|
||||
/* Debug.c */
|
||||
#if defined(DEBUG_MSGS) || !defined(NDEBUG)
|
||||
|
@ -822,23 +817,7 @@ NuError Nu_ExpandHuffmanSQ(NuArchive* pArchive, const NuRecord* pRecord,
|
|||
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc);
|
||||
|
||||
/* Thread.c */
|
||||
#ifdef COMPILE_THREAD_C
|
||||
#define THREAD_INLINE /**/
|
||||
#else
|
||||
#define THREAD_INLINE extern inline
|
||||
#endif
|
||||
#if defined(inline) && !defined(COMPILE_THREAD_C) /*somebody ovrd inline def?*/
|
||||
NuThread* Nu_GetThread(const NuRecord* pRecord, int idx);
|
||||
#else
|
||||
THREAD_INLINE NuThread*
|
||||
Nu_GetThread(const NuRecord* pRecord, int idx)
|
||||
{
|
||||
if (idx >= (int)pRecord->recTotalThreads)
|
||||
return NULL;
|
||||
else
|
||||
return &pRecord->pThreads[idx];
|
||||
}
|
||||
#endif
|
||||
void Nu_StripHiIfAllSet(char* str);
|
||||
Boolean Nu_IsPresizedThreadID(NuThreadID threadID);
|
||||
Boolean Nu_IsCompressibleThreadID(NuThreadID threadID);
|
||||
|
|
|
@ -64,14 +64,10 @@ If you're using BeOS/PPC, it will also do:
|
|||
Mac OS X
|
||||
========
|
||||
|
||||
This works just like the UNIX version, with the exception that when you link
|
||||
against nufxlib, your project must also link against the Carbon framework.
|
||||
This can be done in ProjectBuilder by using the Add Framework option in the
|
||||
Project menu, or by adding "-framework Carbon" to the gcc command line.
|
||||
This works just like the UNIX version, but includes support for resource
|
||||
forks and Finder file/aux types.
|
||||
|
||||
You'll see some warnings due to some namespace collisions between nufxlib and
|
||||
Carbon, but everything will work fine. Carbon is used to provide support for
|
||||
file types and resource forks.
|
||||
Tested with Xcode v5.1.1 and Mac OS 10.8.5.
|
||||
|
||||
|
||||
Win32
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*
|
||||
* Thread-level operations.
|
||||
*/
|
||||
#define COMPILE_THREAD_C 1
|
||||
#include "NufxLibPriv.h"
|
||||
|
||||
|
||||
|
@ -16,6 +15,17 @@
|
|||
* ===========================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* Returns thread N, or NULL if the index is invalid.
|
||||
*/
|
||||
NuThread* Nu_GetThread(const NuRecord* pRecord, int idx)
|
||||
{
|
||||
if (idx >= (int)pRecord->recTotalThreads)
|
||||
return NULL;
|
||||
else
|
||||
return &pRecord->pThreads[idx];
|
||||
}
|
||||
|
||||
/*
|
||||
* ShrinkIt v3.0.0 had a bug where the filename thread would get created
|
||||
* with the high bits set. We want to undo that without stomping on
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
2015/01/02 fadden
|
||||
- Distinguish Unicode and Mac OS Roman strings.
|
||||
|
||||
2014/12/22 fadden
|
||||
- Source code cleanup.
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "NuLib2.h"
|
||||
|
||||
|
||||
static const char* gProgramVersion = "3.0.0";
|
||||
static const char* gProgramVersion = "3.0.0d2";
|
||||
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue