fix problems with opening and using wordlists on 64-bit linux by

making XP_U32 32 rather than 64 bits. Duh. Do same on Android jni just
in case.
This commit is contained in:
Eric House 2014-01-07 06:58:20 -08:00
parent 459c12d91f
commit e34cc9007d
15 changed files with 53 additions and 53 deletions

View file

@ -28,11 +28,11 @@
typedef unsigned char XP_U8;
typedef signed char XP_S8;
typedef unsigned short XP_U16;
typedef signed short XP_S16;
typedef uint16_t XP_U16;
typedef int16_t XP_S16;
typedef unsigned long XP_U32;
typedef signed long XP_S32;
typedef uint32_t XP_U32;
typedef int32_t XP_S32;
typedef char XP_UCHAR;
@ -46,7 +46,7 @@ typedef XP_U32 XP_Time;
#define XP_S "%s"
#define XP_P "%p"
#define XP_CR "\n"
#define XP_LD "%ld"
#define XP_LD "%d"
# define XP_RANDOM() rand()

View file

@ -437,7 +437,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_initJNI
globals->vtMgr = make_vtablemgr(MPPARM_NOCOMMA(mpool));
XP_U32 secs = getCurSeconds( env );
XP_LOGF( "initing srand with %ld", secs );
XP_LOGF( "initing srand with %d", secs );
srandom( secs );
return (jint) state;

View file

@ -1333,7 +1333,7 @@ board_popTimerSave( BoardCtxt* board )
XP_ASSERT( board->timerStoppedTime != 0 );
elapsed = curTime - board->timerStoppedTime;
XP_LOGF( "board_popTimerSave: elapsed=%ld", elapsed );
XP_LOGF( "board_popTimerSave: elapsed=%d", elapsed );
XP_ASSERT( elapsed <= 0xFFFF );
board->gi->players[turn].secondsUsed += (XP_U16)elapsed;
}

View file

@ -489,7 +489,7 @@ comms_setConnID( CommsCtxt* comms, XP_U32 connID )
XP_ASSERT( CONN_ID_NONE != connID );
XP_ASSERT( 0 == comms->connID || connID == comms->connID );
comms->connID = connID;
XP_LOGF( "%s: set connID (gameID) to %lx", __func__, connID );
XP_LOGF( "%s: set connID (gameID) to %x", __func__, connID );
} /* comms_setConnID */
static void
@ -822,8 +822,8 @@ comms_saveSucceeded( CommsCtxt* comms, XP_U16 saveToken )
if ( saveToken == comms->lastSaveToken ) {
AddressRecord* rec;
for ( rec = comms->recs; !!rec; rec = rec->next ) {
XP_LOGF( "%s: lastSave matches; updating lastMsgSaved (%ld) to "
"lastMsgRcd (%ld)", __func__, rec->lastMsgSaved,
XP_LOGF( "%s: lastSave matches; updating lastMsgSaved (%d) to "
"lastMsgRcd (%d)", __func__, rec->lastMsgSaved,
rec->lastMsgRcd );
rec->lastMsgSaved = rec->lastMsgRcd;
}
@ -989,12 +989,12 @@ makeElemWithID( CommsCtxt* comms, MsgID msgID, AddressRecord* rec,
NULL, 0,
(MemStreamCloseCallback)NULL );
stream_open( hdrStream );
XP_LOGF( "%s: putting connID %lx", __func__, comms->connID );
XP_LOGF( "%s: putting connID %x", __func__, comms->connID );
stream_putU32( hdrStream, comms->connID );
stream_putU16( hdrStream, channelNo );
stream_putU32( hdrStream, msgID );
XP_LOGF( "put lastMsgSaved: %ld", lastMsgSaved );
XP_LOGF( "put lastMsgSaved: %d", lastMsgSaved );
stream_putU32( hdrStream, lastMsgSaved );
if ( !!rec ) {
rec->lastMsgAckd = lastMsgSaved;
@ -1223,7 +1223,7 @@ gameID( const CommsCtxt* comms )
if ( 0 == gameID ) {
XP_LOGF( "%s: gameID STILL 0", __func__ );
} else if ( 0 == comms->util->gameInfo->gameID ) {
XP_LOGF( "%s: setting gi's gameID to 0X%lX", __func__, gameID );
XP_LOGF( "%s: setting gi's gameID to 0X%X", __func__, gameID );
comms->util->gameInfo->gameID = gameID;
}
@ -1307,7 +1307,7 @@ comms_resendAll( CommsCtxt* comms, XP_Bool force )
XP_U32 now = util_getCurSeconds( comms->util );
if ( !force && (now < comms->nextResend) ) {
XP_LOGF( "%s: aborting: %ld seconds left in backoff", __func__,
XP_LOGF( "%s: aborting: %d seconds left in backoff", __func__,
comms->nextResend - now );
success = XP_FALSE;
@ -1347,7 +1347,7 @@ comms_ackAny( CommsCtxt* comms )
#ifdef DEBUG
++nSent;
#endif
XP_LOGF( "%s: channel %x; %ld < %ld: rec needs ack", __func__,
XP_LOGF( "%s: channel %x; %d < %d: rec needs ack", __func__,
rec->channelNo, rec->lastMsgAckd, rec->lastMsgRcd );
sendEmptyMsg( comms, rec );
}
@ -1844,7 +1844,7 @@ validateChannelMessage( CommsCtxt* comms, const CommsAddrRec* addr,
if ( msgID == rec->lastMsgRcd + 1 ) {
updateChannelAddress( rec, addr );
} else {
XP_LOGF( "%s: expected %ld, got %ld", __func__,
XP_LOGF( "%s: expected %d, got %d", __func__,
rec->lastMsgRcd + 1, msgID );
rec = NULL;
}
@ -1894,11 +1894,11 @@ comms_checkIncomingStream( CommsCtxt* comms, XWStreamCtxt* stream,
AddressRecord* rec = NULL;
connID = stream_getU32( stream );
XP_LOGF( "%s: read connID (gameID) of %lx", __func__, connID );
XP_LOGF( "%s: read connID (gameID) of %x", __func__, connID );
channelNo = stream_getU16( stream );
msgID = stream_getU32( stream );
lastMsgRcd = stream_getU32( stream );
XP_LOGF( "%s: rcd on channelNo %d(%x): msgID=%ld,lastMsgRcd=%ld ",
XP_LOGF( "%s: rcd on channelNo %d(%x): msgID=%d,lastMsgRcd=%d ",
__func__, channelNo & CHANNEL_MASK, channelNo,
msgID, lastMsgRcd );
@ -1918,7 +1918,7 @@ comms_checkIncomingStream( CommsCtxt* comms, XWStreamCtxt* stream,
messageValid = (NULL != rec)
&& (0 == rec->lastMsgRcd || rec->lastMsgRcd <= msgID);
if ( messageValid ) {
XP_LOGF( "%s: got channelNo=%d;msgID=%ld;len=%d", __func__,
XP_LOGF( "%s: got channelNo=%d;msgID=%d;len=%d", __func__,
channelNo & CHANNEL_MASK, msgID, payloadSize );
rec->lastMsgRcd = msgID;
comms->lastSaveToken = 0; /* lastMsgRcd no longer valid */
@ -2150,7 +2150,7 @@ comms_getStats( CommsCtxt* comms, XWStreamCtxt* stream )
stream_catString( stream, buf );
XP_SNPRINTF( (XP_UCHAR*)buf, sizeof(buf),
(XP_UCHAR*)"Last message received: %ld\n",
(XP_UCHAR*)"Last message received: %d\n",
rec->lastMsgRcd );
stream_catString( stream, buf );
}

View file

@ -754,7 +754,7 @@ checkSanity( DictionaryCtxt* dict, const XP_U32 numEdges )
for ( ii = 0; ii < numEdges && passed; ++ii ) {
Tile tile = EDGETILE( dict, edge );
if ( tile < prevTile || tile >= nFaces ) {
XP_LOGF( "%s: node %ld (out of %ld) has too-large or "
XP_LOGF( "%s: node %d (out of %d) has too-large or "
"out-of-order tile", __func__, ii, numEdges );
passed = XP_FALSE;
break;
@ -763,7 +763,7 @@ checkSanity( DictionaryCtxt* dict, const XP_U32 numEdges )
unsigned long index = dict_index_from( dict, edge );
if ( index >= numEdges ) {
XP_LOGF( "%s: node %ld (out of %ld) has too-high index %ld",
XP_LOGF( "%s: node %d (out of %d) has too-high index %ld",
__func__, ii, numEdges, index );
passed = XP_FALSE;
break;

View file

@ -107,7 +107,7 @@ mpool_destroy( MemPoolCtx* mpool )
MemPoolEntry* entry;
for ( entry = mpool->usedList; !!entry; entry = entry->next ) {
#ifndef FOR_GREMLINS /* I don't want to hear about this right now */
XP_LOGF( "%s: " XP_P " index=%d, in %s, ln %ld of %s\n", __func__,
XP_LOGF( "%s: " XP_P " index=%d, in %s, ln %d of %s\n", __func__,
entry->ptr, entry->index,
entry->func, entry->lineNo, entry->fileName );
#ifdef DEBUG
@ -203,7 +203,7 @@ mpool_realloc( MemPoolCtx* mpool, void* ptr, XP_U32 newsize, const char* file,
MemPoolEntry* entry = findEntryFor( mpool, ptr, (MemPoolEntry**)NULL );
if ( !entry ) {
XP_LOGF( "findEntryFor failed; called from %s, line %ld",
XP_LOGF( "findEntryFor failed; called from %s, line %d",
file, lineNo );
} else {
entry->ptr = XP_PLATREALLOC( entry->ptr, newsize );
@ -226,7 +226,7 @@ mpool_free( MemPoolCtx* mpool, void* ptr, const char* file,
entry = findEntryFor( mpool, ptr, &prev );
if ( !entry ) {
XP_LOGF( "findEntryFor failed; called from %s, line %ld in %s",
XP_LOGF( "findEntryFor failed; called from %s, line %d in %s",
func, lineNo, file );
XP_ASSERT( 0 );
} else {
@ -287,14 +287,14 @@ mpool_stats( MemPoolCtx* mpool, XWStreamCtxt* stream )
for ( entry = mpool->usedList; !!entry; entry = entry->next ) {
XP_SNPRINTF( buf, sizeof(buf),
(XP_UCHAR*)"%ld byte block allocated at %p, at line %ld "
(XP_UCHAR*)"%d byte block allocated at %p, at line %d "
"in %s, %s\n", entry->size, entry->ptr, entry->lineNo,
entry->func, entry->fileName );
STREAM_OR_LOG( stream, buf );
total += entry->size;
}
XP_SNPRINTF( buf, sizeof(buf), "total bytes allocated: %ld\n", total );
XP_SNPRINTF( buf, sizeof(buf), "total bytes allocated: %d\n", total );
STREAM_OR_LOG( stream, buf );
} /* mpool_stats */

View file

@ -1261,7 +1261,7 @@ client_readInitialMessage( ServerCtxt* server, XWStreamCtxt* stream )
// XP_ASSERT( streamVersion <= CUR_STREAM_VERS ); /* else do what? */
gameID = stream_getU32( stream );
XP_LOGF( "read gameID of %lx; calling comms_setConnID", gameID );
XP_LOGF( "read gameID of %x; calling comms_setConnID", gameID );
server->vol.gi->gameID = gameID;
comms_setConnID( server->vol.comms, gameID );
@ -1424,7 +1424,7 @@ server_sendInitialMessage( ServerCtxt* server )
stream_putU8( stream, CUR_STREAM_VERS );
#endif
XP_LOGF( "putting gameID %lx into msg", gameID );
XP_LOGF( "putting gameID %x into msg", gameID );
stream_putU32( stream, gameID );
makeSendableGICopy( server, &localGI, deviceIndex );

View file

@ -239,7 +239,7 @@ getRowsForGameID( sqlite3* pDb, XP_U32 gameID, sqlite3_int64* rowids,
*nRowIDs = 0;
char buf[256];
snprintf( buf, sizeof(buf), "SELECT rowid from games WHERE gameid = %ld LIMIT %d",
snprintf( buf, sizeof(buf), "SELECT rowid from games WHERE gameid = %d LIMIT %d",
gameID, maxRowIDs );
sqlite3_stmt *ppStmt;
int result = sqlite3_prepare_v2( pDb, buf, -1, &ppStmt, NULL );

View file

@ -1487,7 +1487,7 @@ handle_invite_button( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
XP_ASSERT( 0 != port );
const CurGameInfo* gi = globals->cGlobals.gi;
gchar gameName[64];
snprintf( gameName, VSIZE(gameName), "Game %ld", gi->gameID );
snprintf( gameName, VSIZE(gameName), "Game %d", gi->gameID );
linux_sms_invite( globals->cGlobals.params, gi, gameName, 1,
phone, port );
}

View file

@ -561,7 +561,7 @@ smsInviteReceived( void* closure, const XP_UCHAR* gameName, XP_U32 gameID,
{
GtkAppGlobals* apg = (GtkAppGlobals*)closure;
LaunchParams* params = apg->params;
XP_LOGF( "%s(gameName=%s, gameID=%ld, dictName=%s, nPlayers=%d, nHere=%d)",
XP_LOGF( "%s(gameName=%s, gameID=%d, dictName=%s, nPlayers=%d, nHere=%d)",
__func__, gameName, gameID, dictName, nPlayers, nHere );
CurGameInfo gi = {0};

View file

@ -218,7 +218,7 @@ dict_splitFaces( DictionaryCtxt* dict, const XP_U8* utf8,
if ( isUTF8 ) {
for ( ; ; ) {
gchar* cp = g_utf8_offset_to_pointer( bytes, 1 );
XP_U16 len = cp - bytes;
size_t len = cp - bytes;
XP_MEMCPY( next, bytes, len );
next += len;
bytes += len;
@ -248,7 +248,7 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const LaunchParams* params,
const char* fileName )
{
XP_Bool formatOk = XP_TRUE;
long curPos, dictLength;
size_t dictLength;
XP_U32 topOffset;
unsigned short xloc;
XP_U16 flags;
@ -343,7 +343,7 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const LaunchParams* params,
ptr += sizeof(wordCount);
headerLen -= sizeof(wordCount);
dctx->super.nWords = ntohl( wordCount );
XP_DEBUGF( "dict contains %ld words", dctx->super.nWords );
XP_DEBUGF( "dict contains %d words", dctx->super.nWords );
if ( 0 < headerLen ) {
dctx->super.desc = getNullTermParam( dctx, &ptr, &headerLen );
@ -371,7 +371,7 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const LaunchParams* params,
|| XP_TRUE
#endif
) {
XP_U32 curPos = ptr - dctx->dictBase;
size_t curPos = ptr - dctx->dictBase;
gssize dictLength = dctx->dictLength - curPos;
gchar* checksum = g_compute_checksum_for_data( G_CHECKSUM_MD5, ptr, dictLength );
@ -410,7 +410,7 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const LaunchParams* params,
XP_U32 numEdges;
skipBitmaps( dctx, &ptr );
curPos = ptr - dctx->dictBase;
size_t curPos = ptr - dctx->dictBase;
dictLength = dctx->dictLength - curPos;
if ( dictLength > 0 ) {
@ -553,12 +553,12 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const char* fileName )
prect = prcgetrecord( pt, 2 );
dataP = (unsigned short*)prect->data + 1; /* skip the xloc header */
for ( i = 0; i < dctx->super.numFaces; ++i ) {
for ( ii = 0; ii < dctx->super.numFaces; ++ii ) {
unsigned short byt = *dataP++;
dctx->super.values[i] = byt >> 8;
dctx->super.counts[i] = byt & 0xFF;
if ( dctx->super.values[i] == 0 ) {
dctx->super.counts[i] = 4; /* 4 blanks :-) */
dctx->super.values[ii] = byt >> 8;
dctx->super.counts[ii] = byt & 0xFF;
if ( dctx->super.values[ii] == 0 ) {
dctx->super.counts[ii] = 4; /* 4 blanks :-) */
}
}

View file

@ -1012,7 +1012,7 @@ sendTimerFired( gpointer data )
SendQueueElem* elem = (SendQueueElem*)cGlobals->packetQueue->data;
cGlobals->packetQueue = cGlobals->packetQueue->next;
XP_LOGF( "%s: sending packet %ld of len %zd (%d left)", __func__,
XP_LOGF( "%s: sending packet %d of len %zd (%d left)", __func__,
elem->id, elem->len, listLen - 1 );
bool sent = send_or_close( cGlobals, elem->buf, elem->len );
free( elem->buf );
@ -1048,7 +1048,7 @@ send_per_params( const XP_U8* buf, const XP_U16 buflen,
cGlobals->packetQueue =
g_slist_append( cGlobals->packetQueue, elem );
nSent += toSend;
XP_LOGF( "%s: added packet %ld of len %zd", __func__,
XP_LOGF( "%s: added packet %d of len %zd", __func__,
elem->id, elem->len );
}
int when = XP_RANDOM() % (1 + cGlobals->params->splitPackets);
@ -1550,7 +1550,7 @@ walk_dict_test( MPFORMAL const DictionaryCtxt* dict,
XP_U32 sum = 0;
for ( jj = 0; jj < VSIZE(lens.lens); ++jj ) {
sum += lens.lens[jj];
XP_LOGF( "%ld words of length %ld", lens.lens[jj], jj );
XP_LOGF( "%d words of length %ld", lens.lens[jj], jj );
}
XP_ASSERT( sum == count );

View file

@ -209,7 +209,7 @@ dispatch_invite( LinSMSData* storage, XP_U16 XP_UNUSED(proto),
XP_UCHAR dictName[256];
XP_U32 gameID = stream_getU32( stream );
XP_LOGF( "%s: got gameID %ld", __func__, gameID );
XP_LOGF( "%s: got gameID %d", __func__, gameID );
stringFromStreamHere( stream, gameName, VSIZE(gameName) );
XP_U32 dictLang = stream_getU32( stream );
stringFromStreamHere( stream, dictName, VSIZE(dictName) );

View file

@ -253,7 +253,7 @@ relaycon_receive( void* closure, int socket )
}
case XWPDEV_UNAVAIL: {
XP_U32 unavail = getNetLong( &ptr );
XP_LOGF( "%s: unavail = %lu", __func__, unavail );
XP_LOGF( "%s: unavail = %u", __func__, unavail );
uint32_t len;
if ( !vli2un( &ptr, &len ) ) {
assert(0);
@ -326,7 +326,7 @@ hostNameToIP( const XP_UCHAR* name )
XP_MEMCPY( &ip, host->h_addr_list[0], sizeof(ip) );
ip = ntohl(ip);
}
XP_LOGF( "%s found %lx for %s", __func__, ip, name );
XP_LOGF( "%s found %x for %s", __func__, ip, name );
return ip;
}

View file

@ -50,11 +50,11 @@ typedef char XP_UCHAR;
# define XP_L(s) ##s
#endif
typedef unsigned short XP_U16;
typedef signed short XP_S16;
typedef uint16_t XP_U16;
typedef int16_t XP_S16;
typedef unsigned long XP_U32;
typedef signed long XP_S32;
typedef uint32_t XP_U32;
typedef int32_t XP_S32;
typedef signed short XP_FontCode; /* not sure how I'm using this yet */
typedef unsigned char XP_Bool;
@ -131,7 +131,7 @@ void linux_backtrace( void );
#define XP_HTONL(l) htonl(l)
#define XP_HTONS(s) htons(s)
#define XP_LD "%ld"
#define XP_LD "%d"
#define XP_P "%p"
#endif