Commit f3afdb75 authored by Shane Snyder's avatar Shane Snyder

move back-compat code out of dedicated directory

parent ddd83318
......@@ -17,8 +17,6 @@ DARSHAN_MOD_LOG_FORMATS = $(srcdir)/../darshan-posix-log-format.h $(srcdir)/../d
DARSHAN_MOD_LOGUTIL_HEADERS = darshan-posix-logutils.h darshan-mpiio-logutils.h darshan-hdf5-logutils.h darshan-pnetcdf-logutils.h
DARSHAN_STATIC_MOD_OBJS = darshan-posix-logutils.o darshan-mpiio-logutils.o darshan-hdf5-logutils.o darshan-pnetcdf-logutils.o darshan-bgq-logutils.o
DARSHAN_DYNAMIC_MOD_OBJS = darshan-posix-logutils.po darshan-mpiio-logutils.po darshan-hdf5-logutils.po darshan-pnetcdf-logutils.po darshan-bgq-logutils.po
DARSHAN_STATIC_COMPAT_OBJS = compat/darshan-logutils-compat.o
DARSHAN_DYNAMIC_COMPAT_OBJS = compat/darshan-logutils-compat.po
DARSHAN_ENABLE_SHARED=@DARSHAN_ENABLE_SHARED@
......@@ -83,12 +81,7 @@ darshan-bgq-logutils.o: darshan-bgq-logutils.c darshan-logutils.h darshan-bgq-lo
darshan-bgq-logutils.po: darshan-bgq-logutils.c darshan-logutils.h darshan-bgq-logutils.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-bgq-log-format.h | uthash-1.9.2
$(CC) $(CFLAGS_SHARED) -c $< -o $@
compat/darshan-logutils-compat.o: compat/darshan-logutils-compat.c compat/darshan-logutils-compat.h darshan-logutils.h $(DARSHAN_LOG_FORMAT) | uthash-1.9.2
$(CC) $(CFLAGS) -c $< -o $@
#compat/darshan-logutils-compat.po: compat/darshan-logutils-compat.c compat/darshan-logutils-compat.h darshan-logutils.h $(DARSHAN_LOG_FORMAT) | uthash-1.9.2
# $(CC) $(CFLAGS_SHARED) -c $< -o $@
libdarshan-util.a: darshan-logutils.o $(DARSHAN_STATIC_MOD_OBJS) $(DARSHAN_STATIC_COMPAT_OBJS)
libdarshan-util.a: darshan-logutils.o $(DARSHAN_STATIC_MOD_OBJS)
ar rcs libdarshan-util.a $^
libdarshan-util.so: darshan-logutils.po $(DARSHAN_DYNAMIC_MOD_OBJS)
......@@ -165,7 +158,7 @@ endif
clean::
rm -f *.o *.po compat/*.o compat/*.po *.a *.so darshan-analyzer darshan-convert darshan-diff darshan-parser darshan-merge jenkins-hash-gen
rm -f *.o *.po *.a *.so darshan-analyzer darshan-convert darshan-diff darshan-parser darshan-merge jenkins-hash-gen
distclean:: clean
rm -f darshan-runtime-config.h aclocal.m4 autom4te.cache/* config.status config.log Makefile util/bin/darshan-job-summary.pl
......
/*
* Copyright (C) 2015 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#define _GNU_SOURCE
#include "darshan-util-config.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/types.h>
#include "darshan-logutils-compat.h"
int darshan_log_get_namerecs_3_00(void *name_rec_buf, int buf_len,
int swap_flag, struct darshan_name_record_ref **hash)
{
struct darshan_name_record_ref *ref;
char *buf_ptr;
darshan_record_id *rec_id_ptr;
uint32_t *path_len_ptr;
char *path_ptr;
int rec_len;
int buf_processed = 0;
/* work through the name record buffer -- deserialize the mapping data and
* add to the output hash table
* NOTE: these mapping pairs are variable in length, so we have to be able
* to handle incomplete mappings temporarily here
*/
buf_ptr = name_rec_buf;
while(buf_len > (sizeof(darshan_record_id) + sizeof(uint32_t)))
{
/* see if we have enough buf space to read in the next full record */
path_len_ptr = (uint32_t *)(buf_ptr + sizeof(darshan_record_id));
if(swap_flag)
DARSHAN_BSWAP32(path_len_ptr);
rec_len = sizeof(darshan_record_id) + sizeof(uint32_t) + *path_len_ptr;
/* we need to read more before we continue deserializing */
if(buf_len < rec_len)
break;
/* get pointers for each field of this darshan record */
/* NOTE: darshan record hash serialization method:
* ... darshan_record_id | (uint32_t) path_len | path ...
*/
rec_id_ptr = (darshan_record_id *)buf_ptr;
path_ptr = (char *)(buf_ptr + sizeof(darshan_record_id) + sizeof(uint32_t));
if(swap_flag)
/* we need to sort out endianness issues before deserializing */
DARSHAN_BSWAP64(rec_id_ptr);
HASH_FIND(hlink, *hash, rec_id_ptr, sizeof(darshan_record_id), ref);
if(!ref)
{
ref = malloc(sizeof(*ref));
if(!ref)
return(-1);
ref->name_record = malloc(rec_len - sizeof(uint32_t) + 1);
if(!ref->name_record)
{
free(ref);
return(-1);
}
/* transform the serialized name record into the zero-length
* array structure darshan uses to track name records
*/
ref->name_record->id = *rec_id_ptr;
memcpy(ref->name_record->name, path_ptr, *path_len_ptr);
ref->name_record->name[*path_len_ptr] = '\0';
/* add this record to the hash */
HASH_ADD(hlink, *hash, name_record->id, sizeof(darshan_record_id), ref);
}
buf_ptr += rec_len;
buf_len -= rec_len;
buf_processed += rec_len;
}
return(buf_processed);
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
/*
* Copyright (C) 2015 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#ifndef __DARSHAN_LOG_UTILS_COMPAT_H
#define __DARSHAN_LOG_UTILS_COMPAT_H
#include "darshan-logutils.h"
int darshan_log_get_namerecs_3_00(void *name_rec_buf, int buf_len,
int swap_flag, struct darshan_name_record_ref **hash);
#endif
......@@ -18,7 +18,6 @@
#include <errno.h>
#include "darshan-logutils.h"
#include "compat/darshan-logutils-compat.h"
/* default input buffer size for decompression algorithm */
#define DARSHAN_DEF_COMP_BUF_SZ (1024*1024) /* 1 MiB */
......@@ -71,6 +70,15 @@ struct darshan_fd_int_state
struct darshan_dz_state dz;
};
/* each module's implementation of the darshan logutil functions */
#define X(a, b, c, d) d,
struct darshan_mod_logutil_funcs *mod_logutils[DARSHAN_MAX_MODS] =
{
DARSHAN_MODULE_IDS
};
#undef X
/* internal helper functions */
static int darshan_mnt_info_cmp(const void *a, const void *b);
static int darshan_log_get_namerecs(void *name_rec_buf, int buf_len,
int swap_flag, struct darshan_name_record_ref **hash);
......@@ -100,13 +108,14 @@ static int darshan_log_dzunload(darshan_fd fd, struct darshan_log_map *map_p);
static int darshan_log_noz_read(darshan_fd fd, struct darshan_log_map map,
void *buf, int len, int reset_strm_flag);
/* each module's implementation of the darshan logutil functions */
#define X(a, b, c, d) d,
struct darshan_mod_logutil_funcs *mod_logutils[DARSHAN_MAX_MODS] =
{
DARSHAN_MODULE_IDS
};
#undef X
/* backwards compatibility functions */
int darshan_log_get_namerecs_3_00(void *name_rec_buf, int buf_len,
int swap_flag, struct darshan_name_record_ref **hash);
/********************************************************
* publically exposed logutil functions *
********************************************************/
/* darshan_log_open()
*
......@@ -754,7 +763,9 @@ void darshan_log_close(darshan_fd fd)
return;
}
/* **************************************************** */
/********************************************************
* internal helper functions *
********************************************************/
static int darshan_mnt_info_cmp(const void *a, const void *b)
{
......@@ -1728,6 +1739,83 @@ static int darshan_log_dzunload(darshan_fd fd, struct darshan_log_map *map_p)
return (0);
}
/********************************************************
* backwards compatibility functions *
********************************************************/
int darshan_log_get_namerecs_3_00(void *name_rec_buf, int buf_len,
int swap_flag, struct darshan_name_record_ref **hash)
{
struct darshan_name_record_ref *ref;
char *buf_ptr;
darshan_record_id *rec_id_ptr;
uint32_t *path_len_ptr;
char *path_ptr;
int rec_len;
int buf_processed = 0;
/* work through the name record buffer -- deserialize the mapping data and
* add to the output hash table
* NOTE: these mapping pairs are variable in length, so we have to be able
* to handle incomplete mappings temporarily here
*/
buf_ptr = name_rec_buf;
while(buf_len > (sizeof(darshan_record_id) + sizeof(uint32_t)))
{
/* see if we have enough buf space to read in the next full record */
path_len_ptr = (uint32_t *)(buf_ptr + sizeof(darshan_record_id));
if(swap_flag)
DARSHAN_BSWAP32(path_len_ptr);
rec_len = sizeof(darshan_record_id) + sizeof(uint32_t) + *path_len_ptr;
/* we need to read more before we continue deserializing */
if(buf_len < rec_len)
break;
/* get pointers for each field of this darshan record */
/* NOTE: darshan record hash serialization method:
* ... darshan_record_id | (uint32_t) path_len | path ...
*/
rec_id_ptr = (darshan_record_id *)buf_ptr;
path_ptr = (char *)(buf_ptr + sizeof(darshan_record_id) + sizeof(uint32_t));
if(swap_flag)
/* we need to sort out endianness issues before deserializing */
DARSHAN_BSWAP64(rec_id_ptr);
HASH_FIND(hlink, *hash, rec_id_ptr, sizeof(darshan_record_id), ref);
if(!ref)
{
ref = malloc(sizeof(*ref));
if(!ref)
return(-1);
ref->name_record = malloc(rec_len - sizeof(uint32_t) + 1);
if(!ref->name_record)
{
free(ref);
return(-1);
}
/* transform the serialized name record into the zero-length
* array structure darshan uses to track name records
*/
ref->name_record->id = *rec_id_ptr;
memcpy(ref->name_record->name, path_ptr, *path_len_ptr);
ref->name_record->name[*path_len_ptr] = '\0';
/* add this record to the hash */
HASH_ADD(hlink, *hash, name_record->id, sizeof(darshan_record_id), ref);
}
buf_ptr += rec_len;
buf_len -= rec_len;
buf_processed += rec_len;
}
return(buf_processed);
}
/*
* Local variables:
* c-indent-level: 4
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment