Skip to content

Commit

Permalink
Merge branch 'open-watcom:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalak authored Feb 9, 2025
2 parents 8069e5e + c1f6782 commit 33f9838
Show file tree
Hide file tree
Showing 25 changed files with 278 additions and 238 deletions.
29 changes: 17 additions & 12 deletions bld/dwarf/util/c/dwdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2025 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -58,6 +59,10 @@ typedef struct buff_entry {
char buff[1];
} buff_entry, *buff_list;

struct orl_io_struct {
FILE *fp;
};

static dw_out_offset sectsizes[DR_DEBUG_NUM_SECTS];
unsigned_8 *sections[DR_DEBUG_NUM_SECTS];

Expand Down Expand Up @@ -97,25 +102,25 @@ orl_return DoSymTable( orl_sec_handle orl_sec_hnd )
}
#endif

static void *objRead( FILE *fp, size_t len )
/******************************************/
static void *objRead( struct orl_io_struct *orlio, size_t len )
/*************************************************************/
{
buff_list ptr;

ptr = TRMemAlloc( sizeof( *buffList ) + len - 1 );
ptr->next = buffList;
buffList = ptr;
if( fread( ptr->buff, 1, len, fp ) != len ) {
if( fread( ptr->buff, 1, len, orlio->fp ) != len ) {
TRMemFree( ptr );
return( NULL );
}
return( ptr->buff );
}

static int objSeek( FILE *fp, long pos, int where )
/*************************************************/
static int objSeek( struct orl_io_struct *orlio, long pos, int where )
/********************************************************************/
{
return( fseek( fp, pos, where ) );
return( fseek( orlio->fp, pos, where ) );
}

static void freeBuffList( void )
Expand Down Expand Up @@ -242,7 +247,7 @@ int main( int argc, char *argv[] )
orl_file_handle o_fhnd;
orl_file_format type;
orl_file_flags o_flags;
FILE *fp;
struct orl_io_struct orlio;
int c;
char *secs[MAX_SECS];
int num_secs = 0;
Expand All @@ -257,8 +262,8 @@ int main( int argc, char *argv[] )

dump.sections++;

fp = fopen( argv[1], "rb" );
if( fp == NULL ) {
orlio.fp = fopen( argv[1], "rb" );
if( orlio.fp == NULL ) {
printf( "Error opening file.\n" );
return( EXIT_FAILURE );
}
Expand All @@ -268,7 +273,7 @@ int main( int argc, char *argv[] )
printf( "Got NULL orl_handle.\n" );
return( EXIT_FAILURE );
}
type = ORLFileIdentify( o_hnd, fp );
type = ORLFileIdentify( o_hnd, &orlio );
if( type == ORL_UNRECOGNIZED_FORMAT ) {
printf( "The object file is not in either ELF, COFF or OMF format." );
return( EXIT_FAILURE );
Expand All @@ -288,7 +293,7 @@ int main( int argc, char *argv[] )
break;
}
printf( " object file.\n" );
o_fhnd = ORLFileInit( o_hnd, fp, type );
o_fhnd = ORLFileInit( o_hnd, &orlio, type );
if( o_fhnd == NULL ) {
printf( "Got NULL orl_file_handle.\n" );
return( EXIT_FAILURE );
Expand Down Expand Up @@ -329,7 +334,7 @@ int main( int argc, char *argv[] )
printf( "Error calling ORLFileFini.\n" );
return( EXIT_FAILURE );
}
if( fclose( fp ) ) {
if( fclose( orlio.fp ) ) {
printf( "Error closing file.\n" );
return( EXIT_FAILURE );
}
Expand Down
51 changes: 27 additions & 24 deletions bld/mstools/c/fuzzy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2024 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2024-2025 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -74,6 +74,9 @@ typedef struct _MatchingInfo {
ListElem * found;
} MatchingInfo;

struct orl_io_struct {
FILE *fp;
};

/*
* Static data.
Expand Down Expand Up @@ -180,15 +183,15 @@ static unsigned hash_symbol_name( const void *symbol )
/*
* Used by ORL.
*/
static void *obj_read( FILE *fp, size_t len )
/*******************************************/
static void *obj_read( struct orl_io_struct *orlio, size_t len )
/**************************************************************/
{
ListElem * newelem;

newelem = AllocMem( sizeof( ListElem ) + len - 1 );
newelem->next = bufflist;
bufflist = newelem;
if( fread( newelem->buff, 1, len, fp ) != len ) {
if( fread( newelem->buff, 1, len, orlio->fp ) != len ) {
FreeMem( newelem );
return( NULL );
}
Expand All @@ -199,10 +202,10 @@ static void *obj_read( FILE *fp, size_t len )
/*
* Used by ORL.
*/
static int obj_seek( FILE *fp, long pos, int where )
/**************************************************/
static int obj_seek( struct orl_io_struct *orlio, long pos, int where )
/*********************************************************************/
{
return( fseek( fp, pos, where ) );
return( fseek( orlio->fp, pos, where ) );
}


Expand Down Expand Up @@ -251,52 +254,52 @@ static orl_return do_orl_symbol( orl_symbol_handle o_symbol )
static int handle_obj_file( const char *filename, orl_handle o_hnd )
/******************************************************************/
{
orl_file_handle o_fhnd;
orl_file_format o_format;
orl_file_type o_filetype;
orl_sec_handle o_symtab;
orl_return o_rc;
FILE *fp;
orl_file_handle o_fhnd;
orl_file_format o_format;
orl_file_type o_filetype;
orl_sec_handle o_symtab;
orl_return o_rc;
struct orl_io_struct orlio;

/*** Make ORL interested in the file ***/
fp = fopen( filename, "rb" );
if( fp == NULL ) {
orlio.fp = fopen( filename, "rb" );
if( orlio.fp == NULL ) {
return( 0 );
}
o_format = ORLFileIdentify( o_hnd, fp );
o_format = ORLFileIdentify( o_hnd, &orlio );
if( o_format == ORL_UNRECOGNIZED_FORMAT ) {
fclose( fp );
fclose( orlio.fp );
return( 0 );
}
o_fhnd = ORLFileInit( o_hnd, fp, o_format );
o_fhnd = ORLFileInit( o_hnd, &orlio, o_format );
if( o_fhnd == NULL ) {
fclose( fp );
fclose( orlio.fp );
return( 0 );
}
o_filetype = ORLFileGetType( o_fhnd );
if( o_filetype != ORL_FILE_TYPE_OBJECT ) {
fclose( fp );
fclose( orlio.fp );
return( 0 );
}

/*** Scan the file's symbol table ***/
o_symtab = ORLFileGetSymbolTable( o_fhnd );
if( o_symtab == NULL ) {
fclose( fp );
fclose( orlio.fp );
return( 0 );
}
o_rc = ORLSymbolSecScan( o_symtab, do_orl_symbol );
if( o_rc != ORL_OKAY ) {
fclose( fp );
fclose( orlio.fp );
return( 0 );
}
o_rc = ORLFileFini( o_fhnd );
if( o_rc != ORL_OKAY ) {
fclose( fp );
fclose( orlio.fp );
return( 0 );
}

fclose( fp );
fclose( orlio.fp );
return( 1 );
}

Expand Down
32 changes: 18 additions & 14 deletions bld/ndisasm/stand/c/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2025 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -55,13 +55,6 @@
#include "clibext.h"


struct recognized_struct {
const char *name;
section_type type;
};

typedef struct recognized_struct recognized_struct;

#define SEC_NAME_LEN 8

#define HANDLE_TO_SECTION_TABLE_SIZE 53
Expand All @@ -72,6 +65,17 @@ typedef struct recognized_struct recognized_struct;
#define CPP_COMMENT_STRING "// "
#define MASM_COMMENT_STRING "; "

struct recognized_struct {
const char *name;
section_type type;
};

typedef struct recognized_struct recognized_struct;

struct orl_io_struct {
FILE *fp;
};

char *CommentString = CPP_COMMENT_STRING;

orl_machine_type MachineType;
Expand Down Expand Up @@ -448,12 +452,12 @@ static return_val openFiles( void )
return( RC_OKAY );
}

static void *objRead( FILE *fp, size_t len )
/******************************************/
static void *objRead( struct orl_io_struct *orlio, size_t len )
/*************************************************************/
{
void *retval;

/* unused parameters */ (void)fp;
/* unused parameters */ (void)orlio;

if( (unsigned long)( objFilePos + len ) > objFileLen )
return NULL;
Expand All @@ -462,10 +466,10 @@ static void *objRead( FILE *fp, size_t len )
return retval;
}

static int objSeek( FILE *fp, long pos, int where )
/*************************************************/
static int objSeek( struct orl_io_struct *orlio, long pos, int where )
/********************************************************************/
{
/* unused parameters */ (void)fp;
/* unused parameters */ (void)orlio;

if( where == SEEK_SET ) {
objFilePos = pos;
Expand Down
51 changes: 26 additions & 25 deletions bld/nwlib/c/orlrtns.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2023-2024 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2023-2025 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -36,37 +36,38 @@
#include "clibext.h"


#define FP2OF( fid ) ((obj_file *)(fid))
#define OF2FP( of ) ((FILE *)(of))
struct orl_io_struct {
obj_file ofile;
};

static orl_handle ORLHnd;

static void *ORLObjRead( FILE *fp, size_t len )
/*********************************************/
static void *ORLObjRead( struct orl_io_struct *orlio, size_t len )
/****************************************************************/
{
buf_list *buf;

buf = MemAlloc( len + sizeof( buf_list ) - 1 );
if( LibRead( FP2OF( fp )->io, buf->buf, len ) != len ) {
if( LibRead( orlio->ofile.io, buf->buf, len ) != len ) {
MemFree( buf );
return( NULL );
}
buf->next = FP2OF( fp )->buflist;
FP2OF( fp )->buflist = buf;
buf->next = orlio->ofile.buflist;
orlio->ofile.buflist = buf;
return( buf->buf );
}

static int ORLObjSeek( FILE *fp, long pos, int where )
/****************************************************/
static int ORLObjSeek( struct orl_io_struct *orlio, long pos, int where )
/***********************************************************************/
{
switch( where ) {
case SEEK_SET:
pos += FP2OF( fp )->offset;
pos += orlio->ofile.offset;
break;
case SEEK_CUR:
break;
}
LibSeek( FP2OF( fp )->io, pos, where );
LibSeek( orlio->ofile.io, pos, where );
return( 0 );
}

Expand Down Expand Up @@ -104,24 +105,24 @@ void InitORLObj( void )
static obj_file *DoOpenORLObjFile( libfile io, long offset, const char *name )
/****************************************************************************/
{
obj_file *ofile;
orl_file_format format;

ofile = MemAlloc( sizeof( *ofile ) );
ofile->io = io;
ofile->buflist = NULL;
ofile->offset = offset;
format = ORLFileIdentify( ORLHnd, OF2FP( ofile ) );
struct orl_io_struct *orlio;
orl_file_format format;

orlio = MemAlloc( sizeof( *orlio ) );
orlio->ofile.io = io;
orlio->ofile.buflist = NULL;
orlio->ofile.offset = offset;
format = ORLFileIdentify( ORLHnd, orlio );
switch( format ) {
case ORL_COFF:
case ORL_ELF:
ofile->orl = ORLFileInit( ORLHnd, OF2FP( ofile ), format );
orlio->ofile.orl = ORLFileInit( ORLHnd, orlio, format );
if( Options.libtype == WL_LTYPE_MLIB ) {
if( (ORLFileGetFlags( ofile->orl ) & VALID_ORL_FLAGS) != VALID_ORL_FLAGS ) {
if( (ORLFileGetFlags( orlio->ofile.orl ) & VALID_ORL_FLAGS) != VALID_ORL_FLAGS ) {
FatalError( ERR_NOT_LIB, "64-bit or big-endian", ctext_WL_LTYPE_MLIB );
}
}
if( ofile->orl == NULL ) {
if( orlio->ofile.orl == NULL ) {
FatalError( ERR_CANT_OPEN, name, strerror( errno ) );
}
break;
Expand All @@ -130,10 +131,10 @@ static obj_file *DoOpenORLObjFile( libfile io, long offset, const char *name )
/*
* unrecognized or ORL unused format
*/
ofile->orl = NULL;
orlio->ofile.orl = NULL;
break;
}
return( ofile );
return( (obj_file *)orlio );
}

obj_file *OpenORLObjFile( const char *name )
Expand Down
Loading

0 comments on commit 33f9838

Please sign in to comment.