Commit 0da31a58 authored by Shane Snyder's avatar Shane Snyder
Browse files

initial darshan core shutdown logic

-also, darshan core uses utlist to keep track of modules
parent 40c8ed2e
......@@ -29,7 +29,7 @@ struct darshan_core_module
{
char name[DARSHAN_MOD_NAME_LEN+1];
struct darshan_module_funcs mod_funcs;
struct darshan_core_module *next_mod;
struct darshan_core_module *next;
};
/* in memory structure to keep up with job level data */
......
......@@ -19,6 +19,7 @@
#include <mpi.h>
#include "darshan-core.h"
#include "utlist.h"
extern char* __progname_full;
......@@ -26,12 +27,21 @@ static void darshan_core_initialize(int *argc, char ***argv);
static void darshan_core_shutdown(void);
/* internal variables */
static struct darshan_core_job_runtime *darshan_global_job = NULL;
static struct darshan_core_job_runtime *darshan_core_job = NULL;
static pthread_mutex_t darshan_mutex = PTHREAD_MUTEX_INITIALIZER;
#define DARSHAN_LOCK() pthread_mutex_lock(&darshan_mutex)
#define DARSHAN_UNLOCK() pthread_mutex_unlock(&darshan_mutex)
#define DARSHAN_MOD_REGISTER(__mod) \
LL_PREPEND(darshan_core_job->mod_list_head, __mod)
#define DARSHAN_MOD_SEARCH(__mod, __tmp) \
LL_SEARCH(darshan_core_job->mod_list_head, __mod, __tmp, mod_cmp)
#define DARSHAN_MOD_ITER(__mod, __tmp) \
LL_FOREACH_SAFE(darshan_core_job->mod_list_head, __mod, __tmp)
#define DARSHAN_MOD_DELETE(__mod) \
LL_DELETE(darshan_core_job->mod_list_head, __mod)
/* intercept MPI initialize and finalize to initialize darshan */
int MPI_Init(int *argc, char ***argv)
{
......@@ -53,7 +63,7 @@ int MPI_Init_thread(int *argc, char ***argv, int required, int *provided)
int ret;
ret = DARSHAN_MPI_CALL(PMPI_Init_thread)(argc, argv, required, provided);
if (ret != MPI_SUCCESS)
if(ret != MPI_SUCCESS)
{
return(ret);
}
......@@ -73,6 +83,8 @@ int MPI_Finalize(void)
return(ret);
}
/* *********************************** */
static void darshan_core_initialize(int *argc, char ***argv)
{
int i;
......@@ -90,40 +102,39 @@ static void darshan_core_initialize(int *argc, char ***argv)
if(getenv("DARSHAN_INTERNAL_TIMING"))
internal_timing_flag = 1;
if (internal_timing_flag)
if(internal_timing_flag)
init_start = DARSHAN_MPI_CALL(PMPI_Wtime)();
/* setup darshan runtime if darshan is enabled and hasn't been initialized already */
if (!getenv("DARSHAN_DISABLE") && !darshan_global_job)
if(!getenv("DARSHAN_DISABLE") && !darshan_core_job)
{
/* allocate structure to track darshan_global_job information */
darshan_global_job = malloc(sizeof(*darshan_global_job));
if (darshan_global_job)
/* allocate structure to track darshan_core_job information */
darshan_core_job = malloc(sizeof(*darshan_core_job));
if(darshan_core_job)
{
memset(darshan_global_job, 0, sizeof(*darshan_global_job));
memset(darshan_core_job, 0, sizeof(*darshan_core_job));
if (getenv("DARSHAN_DISABLE_TIMING"))
if(getenv("DARSHAN_DISABLE_TIMING"))
{
darshan_global_job->flags |= CP_FLAG_NOTIMING;
darshan_core_job->flags |= CP_FLAG_NOTIMING;
}
strcpy(darshan_global_job->log_job.version_string, CP_VERSION);
darshan_global_job->log_job.magic_nr = CP_MAGIC_NR;
darshan_global_job->log_job.uid = getuid();
darshan_global_job->log_job.start_time = time(NULL);
darshan_global_job->log_job.nprocs = nprocs;
darshan_global_job->wtime_offset = DARSHAN_MPI_CALL(PMPI_Wtime)();
darshan_global_job->mod_list_head = NULL;
strcpy(darshan_core_job->log_job.version_string, CP_VERSION);
darshan_core_job->log_job.magic_nr = CP_MAGIC_NR;
darshan_core_job->log_job.uid = getuid();
darshan_core_job->log_job.start_time = time(NULL);
darshan_core_job->log_job.nprocs = nprocs;
darshan_core_job->wtime_offset = DARSHAN_MPI_CALL(PMPI_Wtime)();
/* record exe and arguments */
for(i=0; i<(*argc); i++)
{
chars_left = CP_EXE_LEN-strlen(darshan_global_job->exe);
strncat(darshan_global_job->exe, *(argv[i]), chars_left);
chars_left = CP_EXE_LEN-strlen(darshan_core_job->exe);
strncat(darshan_core_job->exe, *(argv[i]), chars_left);
if(i < ((*argc)-1))
{
chars_left = CP_EXE_LEN-strlen(darshan_global_job->exe);
strncat(darshan_global_job->exe, " ", chars_left);
chars_left = CP_EXE_LEN-strlen(darshan_core_job->exe);
strncat(darshan_core_job->exe, " ", chars_left);
}
}
......@@ -132,17 +143,17 @@ static void darshan_core_initialize(int *argc, char ***argv)
*/
if(argc == 0)
{
chars_left = CP_EXE_LEN-strlen(darshan_global_job->exe);
strncat(darshan_global_job->exe, __progname_full, chars_left);
chars_left = CP_EXE_LEN-strlen(darshan_global_job->exe);
strncat(darshan_global_job->exe, " <unknown args>", chars_left);
chars_left = CP_EXE_LEN-strlen(darshan_core_job->exe);
strncat(darshan_core_job->exe, __progname_full, chars_left);
chars_left = CP_EXE_LEN-strlen(darshan_core_job->exe);
strncat(darshan_core_job->exe, " <unknown args>", chars_left);
}
if(chars_left == 0)
{
/* we ran out of room; mark that string was truncated */
truncate_offset = CP_EXE_LEN - strlen(truncate_string);
sprintf(&darshan_global_job->exe[truncate_offset], "%s",
sprintf(&darshan_core_job->exe[truncate_offset], "%s",
truncate_string);
}
}
......@@ -165,16 +176,31 @@ static void darshan_core_initialize(int *argc, char ***argv)
static void darshan_core_shutdown()
{
struct darshan_core_module *mod, *tmp;
int internal_timing_flag = 0;
if(getenv("DARSHAN_INTERNAL_TIMING"))
internal_timing_flag = 1;
printf("darshan SHUTDOWN\n");
/* TODO: coordinate shutdown accross all registered modules */
DARSHAN_MOD_ITER(mod, tmp)
{
printf("Shutting down %s module\n", mod->name);
DARSHAN_MOD_DELETE(mod);
free(mod);
};
free(darshan_core_job);
return;
}
static int mod_cmp(struct darshan_core_module* a, struct darshan_core_module* b)
{
return strcmp(a->name, b->name);
}
/* ********************************************************* */
void darshan_core_register_module(
......@@ -182,44 +208,46 @@ void darshan_core_register_module(
struct darshan_module_funcs *funcs,
int *runtime_mem_limit)
{
struct darshan_core_module *tmp;
struct darshan_core_module *new_mod;
struct darshan_core_module tmp;
struct darshan_core_module* mod;
*runtime_mem_limit = 0;
if (!darshan_global_job)
if(!darshan_core_job)
return;
DARSHAN_LOCK();
tmp = darshan_global_job->mod_list_head;
while(tmp)
/* see if this module is already registered */
strncpy(tmp.name, name, DARSHAN_MOD_NAME_LEN);
DARSHAN_MOD_SEARCH(mod, &tmp);
if(mod)
{
/* silently return if this module is already registered */
if (strcmp(tmp->name, name) == 0)
{
DARSHAN_UNLOCK();
return;
}
tmp = tmp->next_mod;
/* if module is already registered, update module_funcs and return */
/* NOTE: we do not recalculate memory limit here, just set to 0 */
mod->mod_funcs = *funcs;
DARSHAN_UNLOCK();
return;
}
/* allocate new module and add to the head of the linked list of darshan modules */
new_mod = malloc(sizeof(*new_mod));
if (!new_mod)
/* this module has not been registered yet, allocate and register it */
mod = malloc(sizeof(*mod));
if(!mod)
{
DARSHAN_UNLOCK();
return;
}
memset(mod, 0, sizeof(*mod));
memset(new_mod, 0, sizeof(*new_mod));
strncpy(new_mod->name, name, DARSHAN_MOD_NAME_LEN);
new_mod->mod_funcs = *funcs;
new_mod->next_mod = darshan_global_job->mod_list_head;
darshan_global_job->mod_list_head = new_mod;
DARSHAN_UNLOCK();
strncpy(mod->name, name, DARSHAN_MOD_NAME_LEN);
mod->mod_funcs = *funcs;
DARSHAN_MOD_REGISTER(mod);
/* TODO: something smarter than just 2 MiB per module */
*runtime_mem_limit = 2 * 1024 * 1024;
DARSHAN_UNLOCK();
return;
}
......@@ -231,7 +259,7 @@ void darshan_core_lookup_id(
{
darshan_file_id tmp_id;
if (!darshan_global_job)
if(!darshan_core_job)
return;
/* TODO: what do you do with printable flag? */
......@@ -247,7 +275,7 @@ void darshan_core_lookup_id(
double darshan_core_wtime()
{
if(!darshan_global_job || darshan_global_job->flags & CP_FLAG_NOTIMING)
if(!darshan_core_job || darshan_core_job->flags & CP_FLAG_NOTIMING)
{
return(0);
}
......
......@@ -360,6 +360,36 @@ static void posix_runtime_initialize()
if(posix_runtime)
return;
/* register the posix module with darshan core */
darshan_core_register_module(
POSIX_MOD_NAME,
&posix_mod_fns,
&mem_limit);
/* return if no memory assigned by darshan core */
if(mem_limit == 0)
return;
posix_runtime = malloc(sizeof(*posix_runtime));
if(!posix_runtime)
return;
memset(posix_runtime, 0, sizeof(*posix_runtime));
/* set maximum number of file records according to max memory limit */
/* NOTE: maximum number of records is based on the size of a posix file record */
posix_runtime->file_array_size = mem_limit / sizeof(struct darshan_posix_file);
/* allocate array of runtime file records */
posix_runtime->file_array = malloc(sizeof(struct posix_runtime_file) *
posix_runtime->file_array_size);
if(!posix_runtime->file_array)
{
posix_runtime->file_array_size = 0;
return;
}
memset(posix_runtime->file_array, 0, sizeof(struct posix_runtime_file) *
posix_runtime->file_array_size);
#if 0
/* set the memory alignment according to config or environment variables */
#if (__CP_MEM_ALIGNMENT < 1)
......@@ -387,31 +417,11 @@ static void posix_runtime_initialize()
}
#endif
posix_runtime = malloc(sizeof(*posix_runtime));
if(!posix_runtime)
return;
memset(posix_runtime, 0, sizeof(*posix_runtime));
/* register the posix module with darshan core */
darshan_core_register_module(
POSIX_MOD_NAME,
&posix_mod_fns,
&mem_limit);
/* set maximum number of file records according to max memory limit */
/* NOTE: maximum number of records is based on the size of a posix file record */
posix_runtime->file_array_size = mem_limit / sizeof(struct darshan_posix_file);
return;
}
/* allocate array of runtime file records */
posix_runtime->file_array = malloc(sizeof(struct posix_runtime_file) *
posix_runtime->file_array_size);
if(!posix_runtime->file_array)
{
posix_runtime->file_array_size = 0;
return;
}
memset(posix_runtime->file_array, 0, sizeof(struct posix_runtime_file) *
posix_runtime->file_array_size);
static void posix_runtime_finalize()
{
return;
}
......@@ -529,6 +539,9 @@ static void posix_prepare_for_shutdown()
static void posix_get_output_data(void **buffer, int size)
{
/* shutdown the posix runtime module */
posix_runtime_finalize();
return;
}
......
/*
Copyright (c) 2007-2010, Troy D. Hanson http://uthash.sourceforge.net
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UTLIST_H
#define UTLIST_H
#define UTLIST_VERSION 1.9.1
/*
* This file contains macros to manipulate singly and doubly-linked lists.
*
* 1. LL_ macros: singly-linked lists.
* 2. DL_ macros: doubly-linked lists.
* 3. CDL_ macros: circular doubly-linked lists.
*
* To use singly-linked lists, your structure must have a "next" pointer.
* To use doubly-linked lists, your structure must "prev" and "next" pointers.
* Either way, the pointer to the head of the list must be initialized to NULL.
*
* ----------------.EXAMPLE -------------------------
* struct item {
* int id;
* struct item *prev, *next;
* }
*
* struct item *list = NULL:
*
* int main() {
* struct item *item;
* ... allocate and populate item ...
* DL_APPEND(list, item);
* }
* --------------------------------------------------
*
* For doubly-linked lists, the append and delete macros are O(1)
* For singly-linked lists, append and delete are O(n) but prepend is O(1)
* The sort macro is O(n log(n)) for all types of single/double/circular lists.
*/
/* These macros use decltype or the earlier __typeof GNU extension.
As decltype is only available in newer compilers (VS2010 or gcc 4.3+
when compiling c++ code), this code uses whatever method is needed
or, for VS2008 where neither is available, uses casting workarounds. */
#ifdef _MSC_VER /* MS compiler */
#if _MSC_VER >= 1600 && __cplusplus /* VS2010 and newer in C++ mode */
#define LDECLTYPE(x) decltype(x)
#else /* VS2008 or older (or VS2010 in C mode) */
#define NO_DECLTYPE
#define LDECLTYPE(x) char*
#endif
#else /* GNU, Sun and other compilers */
#define LDECLTYPE(x) __typeof(x)
#endif
/* for VS2008 we use some workarounds to get around the lack of decltype,
* namely, we always reassign our tmp variable to the list head if we need
* to dereference its prev/next pointers, and save/restore the real head.*/
#ifdef NO_DECLTYPE
#define _SV(elt,list) _tmp = (char*)(list); {char **_alias = (char**)&(list); *_alias = (elt); }
#define _NEXT(elt,list) ((char*)((list)->next))
#define _NEXTASGN(elt,list,to) { char **_alias = (char**)&((list)->next); *_alias=(char*)(to); }
#define _PREV(elt,list) ((char*)((list)->prev))
#define _PREVASGN(elt,list,to) { char **_alias = (char**)&((list)->prev); *_alias=(char*)(to); }
#define _RS(list) { char **_alias = (char**)&(list); *_alias=_tmp; }
#define _CASTASGN(a,b) { char **_alias = (char**)&(a); *_alias=(char*)(b); }
#else
#define _SV(elt,list)
#define _NEXT(elt,list) ((elt)->next)
#define _NEXTASGN(elt,list,to) ((elt)->next)=(to)
#define _PREV(elt,list) ((elt)->prev)
#define _PREVASGN(elt,list,to) ((elt)->prev)=(to)
#define _RS(list)
#define _CASTASGN(a,b) (a)=(b)
#endif
/******************************************************************************
* The sort macro is an adaptation of Simon Tatham's O(n log(n)) mergesort *
* Unwieldy variable names used here to avoid shadowing passed-in variables. *
*****************************************************************************/
#define LL_SORT(list, cmp) \
do { \
LDECLTYPE(list) _ls_p; \
LDECLTYPE(list) _ls_q; \
LDECLTYPE(list) _ls_e; \
LDECLTYPE(list) _ls_tail; \
LDECLTYPE(list) _ls_oldhead; \
LDECLTYPE(list) _tmp; \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
_ls_looping = 1; \
while (_ls_looping) { \
_CASTASGN(_ls_p,list); \
_CASTASGN(_ls_oldhead,list); \
list = NULL; \
_ls_tail = NULL; \
_ls_nmerges = 0; \
while (_ls_p) { \
_ls_nmerges++; \
_ls_q = _ls_p; \
_ls_psize = 0; \
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
_ls_psize++; \
_SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); \
if (!_ls_q) break; \
} \
_ls_qsize = _ls_insize; \
while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \
if (_ls_psize == 0) { \
_ls_e = _ls_q; _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); _ls_qsize--; \
} else if (_ls_qsize == 0 || !_ls_q) { \
_ls_e = _ls_p; _SV(_ls_p,list); _ls_p = _NEXT(_ls_p,list); _RS(list); _ls_psize--; \
} else if (cmp(_ls_p,_ls_q) <= 0) { \
_ls_e = _ls_p; _SV(_ls_p,list); _ls_p = _NEXT(_ls_p,list); _RS(list); _ls_psize--; \
} else { \
_ls_e = _ls_q; _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); _ls_qsize--; \
} \
if (_ls_tail) { \
_SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e); _RS(list); \
} else { \
_CASTASGN(list,_ls_e); \
} \
_ls_tail = _ls_e; \
} \
_ls_p = _ls_q; \
} \
_SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL); _RS(list); \
if (_ls_nmerges <= 1) { \
_ls_looping=0; \
} \
_ls_insize *= 2; \
} \
} else _tmp=NULL; /* quiet gcc unused variable warning */ \
} while (0)
#define DL_SORT(list, cmp) \
do { \
LDECLTYPE(list) _ls_p; \
LDECLTYPE(list) _ls_q; \
LDECLTYPE(list) _ls_e; \
LDECLTYPE(list) _ls_tail; \
LDECLTYPE(list) _ls_oldhead; \
LDECLTYPE(list) _tmp; \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
_ls_looping = 1; \
while (_ls_looping) { \
_CASTASGN(_ls_p,list); \
_CASTASGN(_ls_oldhead,list); \
list = NULL; \
_ls_tail = NULL; \
_ls_nmerges = 0; \
while (_ls_p) { \
_ls_nmerges++; \
_ls_q = _ls_p; \
_ls_psize = 0; \
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
_ls_psize++; \
_SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); \
if (!_ls_q) break; \
} \
_ls_qsize = _ls_insize; \
while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \
if (_ls_psize == 0) { \
_ls_e = _ls_q; _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); _ls_qsize--; \
} else if (_ls_qsize == 0 || !_ls_q) { \
_ls_e = _ls_p; _SV(_ls_p,list); _ls_p = _NEXT(_ls_p,list); _RS(list); _ls_psize--; \
} else if (cmp(_ls_p,_ls_q) <= 0) { \
_ls_e = _ls_p; _SV(_ls_p,list); _ls_p = _NEXT(_ls_p,list); _RS(list); _ls_psize--; \
} else { \
_ls_e = _ls_q; _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); _ls_qsize--; \
} \
if (_ls_tail) { \
_SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e); _RS(list); \
} else { \
_CASTASGN(list,_ls_e); \
} \
_SV(_ls_e,list); _PREVASGN(_ls_e,list,_ls_tail); _RS(list); \
_ls_tail = _ls_e; \
} \
_ls_p = _ls_q; \
} \
_CASTASGN(list->prev, _ls_tail); \
_SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL); _RS(list); \
if (_ls_nmerges <= 1) { \
_ls_looping=0; \
} \
_ls_insize *= 2; \
} \
} else _tmp=NULL; /* quiet gcc unused variable warning */ \
} while (0)
#define CDL_SORT(list, cmp) \
do { \
LDECLTYPE(list) _ls_p; \
LDECLTYPE(list) _ls_q; \
LDECLTYPE(list) _ls_e; \
LDECLTYPE(list) _ls_tail; \
LDECLTYPE(list) _ls_oldhead; \
LDECLTYPE(list) _tmp; \
LDECLTYPE(list) _tmp2; \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
_ls_looping = 1; \
while (_ls_looping) { \
_CASTASGN(_ls_p,list); \
_CASTASGN(_ls_oldhead,list); \
list = NULL; \
_ls_tail = NULL; \
_ls_nmerges = 0; \
while (_ls_p) { \
_ls_nmerges++; \
_ls_q = _ls_p; \
_ls_psize = 0; \
for (_ls_i = 0; _ls_i < _ls_insize; _ls_i++) { \
_ls_psize++; \
_SV(_ls_q,list); \
if (_NEXT(_ls_q,list) == _ls_oldhead) { \
_ls_q = NULL; \
} else { \
_ls_q = _NEXT(_ls_q,list); \
} \
_RS(list); \
if (!_ls_q) break; \
} \
_ls_qsize = _ls_insize; \
while (_ls_psize > 0 || (_ls_qsize > 0 && _ls_q)) { \
if (_ls_psize == 0) { \
_ls_e = _ls_q; _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); _ls_qsize--; \
if (_ls_q == _ls_oldhead) { _ls_q = NULL; } \
} else if (_ls_qsize == 0 || !_ls_q) { \
_ls_e = _ls_p; _SV(_ls_p,list); _ls_p = _NEXT(_ls_p,list); _RS(list); _ls_psize--; \
if (_ls_p == _ls_oldhead) { _ls_p = NULL; } \
} else if (cmp(_ls_p,_ls_q) <= 0) { \
_ls_e = _ls_p; _SV(_ls_p,list); _ls_p = _NEXT(_ls_p,list); _RS(list); _ls_psize--; \
if (_ls_p == _ls_oldhead) { _ls_p = NULL; } \
} else { \
_ls_e = _ls_q; _SV(_ls_q,list); _ls_q = _NEXT(_ls_q,list); _RS(list); _ls_qsize--; \
if (_ls_q == _ls_oldhead) { _ls_q = NULL; } \
} \
if (_ls_tail) { \
_SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_ls_e); _RS(list); \
} else { \
_CASTASGN(list,_ls_e); \
} \
_SV(_ls_e,list); _PREVASGN(_ls_e,list,_ls_tail); _RS(list); \
_ls_tail = _ls_e; \
} \
_ls_p = _ls_q; \
} \
_CASTASGN(list->prev,_ls_tail); \
_CASTASGN(_tmp2,list); \
_SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_tmp2); _RS(list); \
if (_ls_nmerges <= 1) { \
_ls_looping=0; \
} \
_ls_insize *= 2; \
} \
} else _tmp=NULL; /* quiet gcc unused variable warning */ \
} while (0)
/******************************************************************************