Skip to content

Commit

Permalink
remove non-linux files
Browse files Browse the repository at this point in the history
  • Loading branch information
calccrypto committed Jun 22, 2023
1 parent c4f6901 commit 615dec6
Show file tree
Hide file tree
Showing 39 changed files with 393 additions and 2,634 deletions.
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ include_directories(

# copied from configure.ac
# removed __INTEL__ and _FILE_OFFSET_BITS=64
add_compile_definitions(LINUX)
add_compile_definitions(SG_IO)
add_compile_definitions(_GNU_SOURCE) # should probably move this to individual files that need it
add_compile_definitions(PACKAGE_STRING="${PACKAGE_STRING}")
Expand Down
63 changes: 10 additions & 53 deletions src/base/io_buffers.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@
* used by the Worker Threads.
*/
#include "xint.h"
#ifdef DARWIN
#include <sys/shm.h>
#endif

/*----------------------------------------------------------------------------*/
/* xdd_init_io_buffers() - set up the I/O buffers
* This routine will allocate the memory used as the I/O buffer for a Worker
* Thread. The pointer to the buffer (wd_bufp) and the size of the buffer
* Thread. The pointer to the buffer (wd_bufp) and the size of the buffer
* (wd_buf_size) are set in the Worker Data Struct.
*
* This routine will return the pointer to the buffer upon success. If for
* some reason the buffer cannot be allocated then NULL is returned.
* some reason the buffer cannot be allocated then NULL is returned.
*
* For some operating systems, you can use a shared memory segment instead of
* For some operating systems, you can use a shared memory segment instead of
* a normal malloc/valloc memory chunk. This is done using the "-sharedmemory"
* command line option.
*
Expand All @@ -54,8 +51,8 @@
* | |<-Header->| data buffer |
* +-----*----------*-----------------------------------------------------+
* ^ ^
* ^ +-e2e_datap
* +-e2e_hdrp
* ^ +-e2e_datap
* +-e2e_hdrp
*/
unsigned char *
xdd_init_io_buffers(worker_data_t *wdp) {
Expand All @@ -66,9 +63,6 @@ xdd_init_io_buffers(worker_data_t *wdp) {
int buffer_size; // Size of buffer in bytes
int page_size; // Size of a page of memory
int pages; // Size of buffer in pages
#ifdef WIN32
LPVOID lpMsgBuf; /* Used for the error messages */
#endif

tdp = wdp->wd_tdp;
wdp->wd_bufp = NULL;
Expand All @@ -81,7 +75,7 @@ xdd_init_io_buffers(worker_data_t *wdp) {
pages++; // Round up to page size
if ((tdp->td_target_options & TO_ENDTOEND)) {
// Add one page for the e2e header
pages++;
pages++;

// If its XNI, add another page for XNI, better would be for XNI to
// pack all of the header data (and do the hton, ntoh calls)
Expand All @@ -91,22 +85,15 @@ xdd_init_io_buffers(worker_data_t *wdp) {
}
}


// This is the actual size of the I/O buffer
buffer_size = pages * page_size;

/* Check to see if we want to use a shared memory segment and allocate it using shmget() and shmat().
* NOTE: This is not supported by all operating systems.
* NOTE: This is not supported by all operating systems.
*/
if (tdp->td_target_options & TO_SHARED_MEMORY) {
#if (AIX || LINUX || SOLARIS || DARWIN || FREEBSD)
/* In AIX we need to get memory in a shared memory segment to avoid
* the system continually trying to pin each page on every I/O operation */
#if (AIX)
buf_shmid = shmget(IPC_PRIVATE, buffer_size, IPC_CREAT | SHM_LGPAGE |SHM_PIN );
#else
buf_shmid = shmget(IPC_PRIVATE, buffer_size, IPC_CREAT );
#endif
if (buf_shmid < 0) {
fprintf(xgp->errout,"%s: Cannot create shared memory segment\n", xgp->progname);
perror("Reason");
Expand All @@ -124,61 +111,31 @@ xdd_init_io_buffers(worker_data_t *wdp) {
}
if (xgp->global_options & GO_REALLYVERBOSE)
fprintf(xgp->output,"Shared Memory ID allocated and attached, shmid=%d\n",buf_shmid);
#elif (IRIX || WIN32 )
fprintf(xgp->errout,"%s: Shared Memory not supported on this OS - using valloc\n",
xgp->progname);
tdp->td_target_options &= ~TO_SHARED_MEMORY;
#if (IRIX || SOLARIS || LINUX || AIX || DARWIN || FREEBSD)
bufp = valloc(buffer_size);
#else
bufp = malloc(buffer_size);
#endif
#endif
} else { /* Allocate memory the normal way */
#if (AIX || LINUX)
posix_memalign((void **)&bufp, sysconf(_SC_PAGESIZE), buffer_size);
#elif (IRIX || SOLARIS || LINUX || DARWIN || FREEBSD)
bufp = valloc(buffer_size);
#else
bufp = malloc(buffer_size);
#endif
}
/* Check to see if we really allocated some memory */
if (bufp == NULL) {
fprintf(xgp->errout,"%s: cannot allocate %d bytes of memory for I/O buffer\n",
xgp->progname,buffer_size);
fflush(xgp->errout);
#ifdef WIN32
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL);
fprintf(xgp->errout,"Reason:%s",lpMsgBuf);
fflush(xgp->errout);
#else
perror("Reason");
#endif
return(NULL);
}
/* Memory allocation must have succeeded */

/* Lock all pages in memory */
xdd_lock_memory(bufp, buffer_size, "RW BUFFER");

wdp->wd_bufp_allocated = TRUE;
wdp->wd_bufp = bufp;
wdp->wd_buf_size = buffer_size;

return(bufp);
} /* end of xdd_init_io_buffers() */


/*
* Local variables:
* indent-tabs-mode: t
Expand Down
13 changes: 4 additions & 9 deletions src/base/target_cleanup.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#include "xint.h"

/*----------------------------------------------------------------------------*/
/* xdd_target_thread_cleanup() - Perform termination processing of this
/* xdd_target_thread_cleanup() - Perform termination processing of this
* this Target thread.
* Return Values: 0 is good, -1 indicates an error but what are ya gonna do?
*
*
*/
void
xdd_target_thread_cleanup(target_data_t *tdp) {
Expand All @@ -35,7 +35,7 @@ xdd_target_thread_cleanup(target_data_t *tdp) {
// get the next Worker in this chain
wdp = wdp->wd_next_wdp;
}

/* We need to close all file descriptors opened by worker threads in islocal e2e connection */
if (tdp->td_planp->plan_options & PLAN_ENDTOEND_LOCAL) {
wdp = tdp->td_next_wdp;
Expand All @@ -53,11 +53,7 @@ xdd_target_thread_cleanup(target_data_t *tdp) {
if (tdp->td_planp->plan_options & PLAN_ENDTOEND_LOCAL) {
xdd_targetpass_e2e_remove_islocal(tdp);
} else {
#ifdef WIN32
DeleteFile(tdp->td_target_full_pathname);
#else
unlink(tdp->td_target_full_pathname);
#endif
}
}

Expand Down Expand Up @@ -92,6 +88,5 @@ xdd_target_thread_cleanup(target_data_t *tdp) {
perror("reason");
}
}

} // End of xdd_target_thread_cleanup()

} // End of xdd_target_thread_cleanup()
7 changes: 0 additions & 7 deletions src/base/target_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,7 @@ xint_target_init(target_data_t *tdp) {
// nclk_t TimeDelta; // Used the init the Global Clock
// uint32_t sleepseconds;


#if (AIX)
tdp->td_thread_id = thread_self();
#elif (LINUX)
tdp->td_thread_id = syscall(SYS_gettid);
#else
tdp->td_thread_id = tdp->td_pid;
#endif

// Set the pass number
tdp->td_counters.tc_pass_number = 1;
Expand Down
Loading

0 comments on commit 615dec6

Please sign in to comment.