1
/* $Id: ncbi_host_info.c,v 6.6 2003/01/17 19:44:46 lavr Exp $
2
* ===========================================================================
5
* National Center for Biotechnology Information
7
* This software/database is a "United States Government Work" under the
8
* terms of the United States Copyright Act. It was written as part of
9
* the author's official duties as a United States Government employee and
10
* thus cannot be copyrighted. This software/database is freely available
11
* to the public for use. The National Library of Medicine and the U.S.
12
* Government have not placed any restriction on its use or reproduction.
14
* Although all reasonable efforts have been taken to ensure the accuracy
15
* and reliability of the software and data, the NLM and the U.S.
16
* Government do not and cannot warrant the performance or results that
17
* may be obtained by using this software or data. The NLM and the U.S.
18
* Government disclaim all warranties, express or implied, including
19
* warranties of performance, merchantability or fitness for any particular
22
* Please cite the author in any work or product based on this material.
24
* ===========================================================================
26
* Author: Anton Lavrentiev
29
* NCBI host info constructor and getters
33
#include "ncbi_lbsmd.h"
39
/* Not defined on MacOS.9 :-( */
40
# define M_PI 3.14159265358979323846
44
typedef struct SHostInfoTag {
46
double pad; /* for proper 'hinfo' alignment; also as a magic */
51
HOST_INFO HINFO_Create(const void* hinfo, size_t hinfo_size, const char* env)
53
SHOST_Info* host_info;
60
size = sizeof(*host_info) + hinfo_size;
61
if (!(host_info = (SHOST_Info*) malloc(size + (env ? strlen(env) : 0))))
63
host_info->env = env ? strcpy((char*) host_info + size - 1, env) : 0;
64
host_info->pad = M_PI;
65
memcpy(host_info->hinfo, hinfo, hinfo_size);
70
int HINFO_CpuCount(HOST_INFO host_info)
72
if (!host_info || host_info->pad != M_PI)
74
return LBSM_HINFO_CpuCount(host_info->hinfo);
78
int HINFO_TaskCount(HOST_INFO host_info)
80
if (!host_info || host_info->pad != M_PI)
82
return LBSM_HINFO_TaskCount(host_info->hinfo);
86
int/*bool*/ HINFO_LoadAverage(HOST_INFO host_info, double lavg[2])
88
if (!host_info || host_info->pad != M_PI)
90
return LBSM_HINFO_LoadAverage(host_info->hinfo, lavg);
94
int/*bool*/ HINFO_Status(HOST_INFO host_info, double status[2])
96
if (!host_info || host_info->pad != M_PI)
98
return LBSM_HINFO_Status(host_info->hinfo, status);
102
int/*bool*/ HINFO_BLASTParams(HOST_INFO host_info, unsigned int blast[8])
104
if (!host_info || host_info->pad != M_PI)
106
return LBSM_HINFO_BLASTParams(host_info->hinfo, blast);
110
const char* HINFO_Environment(HOST_INFO host_info)
112
if (!host_info || host_info->pad != M_PI)
114
return host_info->env;
119
* --------------------------------------------------------------------------
120
* $Log: ncbi_host_info.c,v $
121
* Revision 6.6 2003/01/17 19:44:46 lavr
122
* Reduce dependencies
124
* Revision 6.5 2002/10/29 22:19:07 lavr
125
* Fix typo in the file description
127
* Revision 6.4 2002/10/29 00:31:08 lavr
128
* Fixed hinfo overflow from the use of precalculated size
130
* Revision 6.3 2002/10/28 21:55:38 lavr
131
* LBSM_HINFO introduced for readability to replace plain "const void*"
133
* Revision 6.2 2002/10/28 20:49:04 lavr
134
* Conditionally define M_PI if it is not already defined by <math.h>
136
* Revision 6.1 2002/10/28 20:13:45 lavr
139
* ==========================================================================