Skip to content

Commit 7692027

Browse files
committed
Fix compilation issues under clang
clang defaults to c99 so remove inline statements (http://clang.llvm.org/compatibility.html#inline ) on functions shared across different translation units. clang's linker doesn't like major numbers over 255 so change how SOREL is generated in Makefile.am.
1 parent 45a3752 commit 7692027

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
lines changed

Makefile.am

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ lib_libiscsi_la_SOURCES += lib/md5.c
4343
endif
4444

4545
SONAME=3
46-
SOREL=$(shell printf "%d%02d%02d" $(subst ., ,$(VERSION)))
46+
SOMAJOR = $(firstword $(version_split))
47+
SOMINOR = $(word 2, $(version_split))
48+
SOREVISION = $(word 3, $(version_split))
49+
SOREL = $(shell echo $(SOMINOR) + $(SOREVISION))
4750
lib_libiscsi_la_LDFLAGS = \
48-
-version-info $(SONAME):$(SOREL):0 -bindir $(bindir) -no-undefined \
51+
-version-info $(SONAME):$(SOMAJOR):$(SOREL) -bindir $(bindir) -no-undefined \
4952
-export-symbols $(srcdir)/lib/libiscsi.syms
5053

5154
# libiscsi utilities

include/iscsi-private.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,13 @@ void iscsi_set_error(struct iscsi_context *iscsi, const char *error_string,
305305
struct scsi_iovector *iscsi_get_scsi_task_iovector_in(struct iscsi_context *iscsi, struct iscsi_in_pdu *in);
306306
struct scsi_iovector *iscsi_get_scsi_task_iovector_out(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
307307

308-
inline void* iscsi_malloc(struct iscsi_context *iscsi, size_t size);
309-
inline void* iscsi_zmalloc(struct iscsi_context *iscsi, size_t size);
310-
inline void* iscsi_realloc(struct iscsi_context *iscsi, void* ptr, size_t size);
311-
inline void iscsi_free(struct iscsi_context *iscsi, void* ptr);
312-
inline char* iscsi_strdup(struct iscsi_context *iscsi, const char* str);
313-
inline void* iscsi_szmalloc(struct iscsi_context *iscsi, size_t size);
314-
inline void iscsi_sfree(struct iscsi_context *iscsi, void* ptr);
308+
void* iscsi_malloc(struct iscsi_context *iscsi, size_t size);
309+
void* iscsi_zmalloc(struct iscsi_context *iscsi, size_t size);
310+
void* iscsi_realloc(struct iscsi_context *iscsi, void* ptr, size_t size);
311+
void iscsi_free(struct iscsi_context *iscsi, void* ptr);
312+
char* iscsi_strdup(struct iscsi_context *iscsi, const char* str);
313+
void* iscsi_szmalloc(struct iscsi_context *iscsi, size_t size);
314+
void iscsi_sfree(struct iscsi_context *iscsi, void* ptr);
315315

316316
unsigned long crc32c(char *buf, int len);
317317

include/scsi-lowlevel.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,10 +1074,10 @@ EXTERN struct scsi_task *scsi_cdb_writeverify16(uint64_t lba, uint32_t xferlen,
10741074

10751075
void *scsi_malloc(struct scsi_task *task, size_t size);
10761076

1077-
inline uint32_t scsi_get_uint32(const unsigned char *c);
1078-
inline uint16_t scsi_get_uint16(const unsigned char *c);
1079-
inline void scsi_set_uint32(unsigned char *c, uint32_t val);
1080-
inline void scsi_set_uint16(unsigned char *c, uint16_t val);
1077+
uint32_t scsi_get_uint32(const unsigned char *c);
1078+
uint16_t scsi_get_uint16(const unsigned char *c);
1079+
void scsi_set_uint32(unsigned char *c, uint32_t val);
1080+
void scsi_set_uint16(unsigned char *c, uint16_t val);
10811081

10821082
#ifdef __cplusplus
10831083
}

lib/init.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
#include "iscsi-private.h"
3434
#include "slist.h"
3535

36-
inline void* iscsi_malloc(struct iscsi_context *iscsi, size_t size) {
36+
void* iscsi_malloc(struct iscsi_context *iscsi, size_t size) {
3737
void * ptr = malloc(size);
3838
if (ptr != NULL) iscsi->mallocs++;
3939
return ptr;
4040
}
4141

42-
inline void* iscsi_zmalloc(struct iscsi_context *iscsi, size_t size) {
42+
void* iscsi_zmalloc(struct iscsi_context *iscsi, size_t size) {
4343
void * ptr = malloc(size);
4444
if (ptr != NULL) {
4545
memset(ptr,0x00,size);
@@ -48,27 +48,27 @@ inline void* iscsi_zmalloc(struct iscsi_context *iscsi, size_t size) {
4848
return ptr;
4949
}
5050

51-
inline void* iscsi_realloc(struct iscsi_context *iscsi, void* ptr, size_t size) {
51+
void* iscsi_realloc(struct iscsi_context *iscsi, void* ptr, size_t size) {
5252
void * _ptr = realloc(ptr, size);
5353
if (_ptr != NULL) {
5454
iscsi->reallocs++;
5555
}
5656
return _ptr;
5757
}
5858

59-
inline void iscsi_free(struct iscsi_context *iscsi, void* ptr) {
59+
void iscsi_free(struct iscsi_context *iscsi, void* ptr) {
6060
if (ptr == NULL) return;
6161
free(ptr);
6262
iscsi->frees++;
6363
}
6464

65-
inline char* iscsi_strdup(struct iscsi_context *iscsi, const char* str) {
65+
char* iscsi_strdup(struct iscsi_context *iscsi, const char* str) {
6666
char *str2 = strdup(str);
6767
if (str2 != NULL) iscsi->mallocs++;
6868
return str2;
6969
}
7070

71-
inline void* iscsi_szmalloc(struct iscsi_context *iscsi, size_t size) {
71+
void* iscsi_szmalloc(struct iscsi_context *iscsi, size_t size) {
7272
void *ptr;
7373
if (size > iscsi->smalloc_size) return NULL;
7474
if (iscsi->smalloc_free > 0) {
@@ -81,7 +81,7 @@ inline void* iscsi_szmalloc(struct iscsi_context *iscsi, size_t size) {
8181
return ptr;
8282
}
8383

84-
inline void iscsi_sfree(struct iscsi_context *iscsi, void* ptr) {
84+
void iscsi_sfree(struct iscsi_context *iscsi, void* ptr) {
8585
if (ptr == NULL) return;
8686
if (iscsi->smalloc_free == SMALL_ALLOC_MAX_FREE) {
8787
/* SMALL_ALLOC_MAX_FREE should be adjusted that this happens rarely */

lib/scsi-lowlevel.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ scsi_pr_type_str(enum scsi_persistent_out_type pr_type)
235235
return value_string_find(pr_type_strings, pr_type);
236236
}
237237

238-
inline uint64_t
238+
uint64_t
239239
scsi_get_uint64(const unsigned char *c)
240240
{
241241
uint64_t val;
@@ -248,7 +248,7 @@ scsi_get_uint64(const unsigned char *c)
248248
return val;
249249
}
250250

251-
inline uint32_t
251+
uint32_t
252252
scsi_get_uint32(const unsigned char *c)
253253
{
254254
uint32_t val;
@@ -259,7 +259,7 @@ scsi_get_uint32(const unsigned char *c)
259259
return val;
260260
}
261261

262-
inline uint16_t
262+
uint16_t
263263
scsi_get_uint16(const unsigned char *c)
264264
{
265265
uint16_t val;
@@ -314,7 +314,7 @@ task_get_uint8(struct scsi_task *task, int offset)
314314
}
315315
}
316316

317-
inline void
317+
void
318318
scsi_set_uint64(unsigned char *c, uint64_t v)
319319
{
320320
uint32_t val;
@@ -327,7 +327,7 @@ scsi_set_uint64(unsigned char *c, uint64_t v)
327327
scsi_set_uint32(c, val);
328328
}
329329

330-
inline void
330+
void
331331
scsi_set_uint32(unsigned char *c, uint32_t val)
332332
{
333333
c[0] = val >> 24;
@@ -336,7 +336,7 @@ scsi_set_uint32(unsigned char *c, uint32_t val)
336336
c[3] = val;
337337
}
338338

339-
inline void
339+
void
340340
scsi_set_uint16(unsigned char *c, uint16_t val)
341341
{
342342
c[0] = val >> 8;

0 commit comments

Comments
 (0)