mirror of
https://github.com/fadden/nulib2.git
synced 2024-05-28 23:41:29 +00:00
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
|
2014/12/22 fadden
|
||||||
- Source code cleanup.
|
- Source code cleanup.
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
* Compute 16-bit CRCs. Depending on the hardware, the table version
|
* Compute 16-bit CRCs. Depending on the hardware, the table version
|
||||||
* might be slower than the loop computation.
|
* might be slower than the loop computation.
|
||||||
*/
|
*/
|
||||||
#define COMPILE_CRC16_C 1
|
|
||||||
#include "NufxLibPriv.h"
|
#include "NufxLibPriv.h"
|
||||||
|
|
||||||
#define CRC_TAB
|
#define CRC_TAB
|
||||||
|
|
|
@ -48,7 +48,6 @@ static NuError Nu_PartiallyValidateNuArchive(const NuArchive* pArchive)
|
||||||
if (pArchive == NULL)
|
if (pArchive == NULL)
|
||||||
return kNuErrInvalidArg;
|
return kNuErrInvalidArg;
|
||||||
|
|
||||||
pArchive = pArchive;
|
|
||||||
if (pArchive->structMagic != kNuArchiveStructMagic)
|
if (pArchive->structMagic != kNuArchiveStructMagic)
|
||||||
return kNuErrBadStruct;
|
return kNuErrBadStruct;
|
||||||
|
|
||||||
|
|
|
@ -563,20 +563,15 @@ NuError Nu_CopyPresizedToArchive(NuArchive* pArchive,
|
||||||
/* Crc16.c */
|
/* Crc16.c */
|
||||||
extern const uint16_t gNuCrc16Table[256];
|
extern const uint16_t gNuCrc16Table[256];
|
||||||
uint16_t Nu_CalcCRC16(uint16_t seed, const uint8_t* ptr, int count);
|
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 /**/
|
* Update the CRC-16.
|
||||||
#else
|
*
|
||||||
#define CRC_INLINE extern inline
|
* _val (uint8_t) is the byte to add to the CRC. It's evaluated once.
|
||||||
#endif
|
* _crc (uint16_t) is the previous CRC. It's evaluated twice.
|
||||||
#if defined(inline) && !defined(COMPILE_CRC16_C) /* somebody ovrd inline def? */
|
* Returns the updated CRC as a uint16_t.
|
||||||
uint16_t Nu_UpdateCRC16(uint8_t val, uint16_t crc);
|
*/
|
||||||
#else
|
#define Nu_UpdateCRC16(_val, _crc) \
|
||||||
CRC_INLINE uint16_t
|
(gNuCrc16Table[(((_crc) >> 8) & 0xff) ^ (_val)] ^ ((_crc) << 8))
|
||||||
Nu_UpdateCRC16(uint8_t val, uint16_t crc)
|
|
||||||
{
|
|
||||||
return (gNuCrc16Table[((crc >> 8) & 0xFF) ^ val] ^ (crc << 8)) & 0xFFFF;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Debug.c */
|
/* Debug.c */
|
||||||
#if defined(DEBUG_MSGS) || !defined(NDEBUG)
|
#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);
|
const NuThread* pThread, FILE* infp, NuFunnel* pFunnel, uint16_t* pCrc);
|
||||||
|
|
||||||
/* Thread.c */
|
/* 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);
|
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);
|
void Nu_StripHiIfAllSet(char* str);
|
||||||
Boolean Nu_IsPresizedThreadID(NuThreadID threadID);
|
Boolean Nu_IsPresizedThreadID(NuThreadID threadID);
|
||||||
Boolean Nu_IsCompressibleThreadID(NuThreadID threadID);
|
Boolean Nu_IsCompressibleThreadID(NuThreadID threadID);
|
||||||
|
|
|
@ -64,14 +64,10 @@ If you're using BeOS/PPC, it will also do:
|
||||||
Mac OS X
|
Mac OS X
|
||||||
========
|
========
|
||||||
|
|
||||||
This works just like the UNIX version, with the exception that when you link
|
This works just like the UNIX version, but includes support for resource
|
||||||
against nufxlib, your project must also link against the Carbon framework.
|
forks and Finder file/aux types.
|
||||||
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.
|
|
||||||
|
|
||||||
You'll see some warnings due to some namespace collisions between nufxlib and
|
Tested with Xcode v5.1.1 and Mac OS 10.8.5.
|
||||||
Carbon, but everything will work fine. Carbon is used to provide support for
|
|
||||||
file types and resource forks.
|
|
||||||
|
|
||||||
|
|
||||||
Win32
|
Win32
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*
|
*
|
||||||
* Thread-level operations.
|
* Thread-level operations.
|
||||||
*/
|
*/
|
||||||
#define COMPILE_THREAD_C 1
|
|
||||||
#include "NufxLibPriv.h"
|
#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
|
* 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
|
* 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
|
2014/12/22 fadden
|
||||||
- Source code cleanup.
|
- Source code cleanup.
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "NuLib2.h"
|
#include "NuLib2.h"
|
||||||
|
|
||||||
|
|
||||||
static const char* gProgramVersion = "3.0.0";
|
static const char* gProgramVersion = "3.0.0d2";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user