diff --git a/src/block_alloc.h b/src/block_alloc.h
index d37edc0bc1e5a49000e6de2404af769289aeb3fe..1d54c4db38e2d2ef451c18957f18211b11dd1513 100644
--- a/src/block_alloc.h
+++ b/src/block_alloc.h
@@ -225,7 +225,7 @@ static void PIKE_CONCAT3(low_init_,DATA,_hash)(size_t size)			     \
 }									     \
 									     \
 									     \
-static void __attribute((unused)) PIKE_CONCAT3(init_,DATA,_hash)(void)       \
+static void ATTRIBUTE((unused)) PIKE_CONCAT3(init_,DATA,_hash)(void)       \
 {									     \
   PIKE_CONCAT3(low_init_,DATA,_hash)(BSIZE);		                     \
 }									     \
diff --git a/src/block_allocator.h b/src/block_allocator.h
index 566830df41978bde2e185e2393a5aa14fe141228..e314915b862fcea88502b366ecc8d988422118a2 100644
--- a/src/block_allocator.h
+++ b/src/block_allocator.h
@@ -52,13 +52,13 @@ typedef void (*ba_walk_callback)(struct ba_iterator *,void*);
 PMOD_EXPORT
 void ba_walk(struct block_allocator * a, ba_walk_callback cb, void * data);
 
-static INLINE int __attribute__((unused)) ba_it_step(struct ba_iterator * it) {
+static INLINE int ATTRIBUTE((unused)) ba_it_step(struct ba_iterator * it) {
     it->cur = (char*)it->cur + it->l.block_size;
 
     return (char*)it->cur < (char*)it->end;
 }
 
-static INLINE void __attribute__((unused)) * ba_it_val(struct ba_iterator * it) {
+static INLINE void ATTRIBUTE((unused)) * ba_it_val(struct ba_iterator * it) {
     return it->cur;
 }
 
@@ -83,7 +83,7 @@ PMOD_EXPORT void ba_free_all(struct block_allocator * a);
 PMOD_EXPORT size_t ba_count(const struct block_allocator * a);
 PMOD_EXPORT void ba_count_all(const struct block_allocator * a, size_t * num, size_t * size);
 
-static INLINE void __attribute__((unused)) ba_init(struct block_allocator * a, unsigned INT32 block_size, unsigned INT32 blocks) {
+static INLINE void ATTRIBUTE((unused)) ba_init(struct block_allocator * a, unsigned INT32 block_size, unsigned INT32 blocks) {
     ba_init_aligned(a, block_size, blocks, 0);
 }
 #endif
diff --git a/src/builtin.cmod b/src/builtin.cmod
index 2c9d64eda105052652b281599ce004e5e85b3f95..3877c0770d1f15cb0b26e58179eca0162255e516 100644
--- a/src/builtin.cmod
+++ b/src/builtin.cmod
@@ -36,7 +36,10 @@
 #include <ctype.h>
 #include <errno.h>
 #include <math.h>
+
+#ifdef HAVE_ARPA_INET_H
 #include <arpa/inet.h>
+#endif /* HAVE_ARPA_INET_H */
 
 #define DEFAULT_CMOD_STORAGE
 
diff --git a/src/gc.h b/src/gc.h
index ce88582d9ae25e4e14451482f2f531b86d1bd11e..70baabfd74e09007a3d8a2e68cd423f501a22684 100644
--- a/src/gc.h
+++ b/src/gc.h
@@ -427,7 +427,7 @@ PMOD_EXPORT extern const char *gc_found_place;
     gc_found_in_type = orig_gc_found_in_type;				\
   } while (0)
 
-static INLINE int __attribute__((unused)) debug_gc_check (void *a, const char *place)
+static INLINE int ATTRIBUTE((unused)) debug_gc_check (void *a, const char *place)
 {
   int res;
   const char *orig_gc_found_place = gc_found_place;
@@ -437,7 +437,7 @@ static INLINE int __attribute__((unused)) debug_gc_check (void *a, const char *p
   return res;
 }
 
-static INLINE int __attribute__((unused)) debug_gc_check_weak (void *a, const char *place)
+static INLINE int ATTRIBUTE((unused)) debug_gc_check_weak (void *a, const char *place)
 {
   int res;
   const char *orig_gc_found_place = gc_found_place;
@@ -690,7 +690,7 @@ PMOD_EXPORT TYPE_T type_from_visit_fn (visit_thing_fn *fn);
 PMOD_EXPORT TYPE_FIELD real_visit_svalues (struct svalue *s, size_t num,
 					   int ref_type, void *extra);
 
-static INLINE int __attribute__((unused)) real_visit_short_svalue (union anything *u, TYPE_T t,
+static INLINE int ATTRIBUTE((unused)) real_visit_short_svalue (union anything *u, TYPE_T t,
 								   int ref_type, void *extra)
 {
   check_short_svalue (u, t);
@@ -702,7 +702,7 @@ static INLINE int __attribute__((unused)) real_visit_short_svalue (union anythin
   (real_visit_short_svalue (debug_malloc_pass ((U)), (T), (REF_TYPE), (EXTRA)))
 
 #ifdef DEBUG_MALLOC
-static INLINE TYPE_FIELD __attribute__((unused)) dmalloc_visit_svalues (struct svalue *s, size_t num,
+static INLINE TYPE_FIELD ATTRIBUTE((unused)) dmalloc_visit_svalues (struct svalue *s, size_t num,
 									int ref_type, char *l, void *extra)
 {
   return real_visit_svalues (dmalloc_check_svalues (s, num, l),
@@ -710,7 +710,7 @@ static INLINE TYPE_FIELD __attribute__((unused)) dmalloc_visit_svalues (struct s
 }
 #define visit_svalues(S, NUM, REF_TYPE, EXTRA)				\
   dmalloc_visit_svalues ((S), (NUM), (REF_TYPE), (EXTRA), DMALLOC_LOCATION())
-static INLINE void __attribute__((unused)) dmalloc_visit_svalue (struct svalue *s,
+static INLINE void ATTRIBUTE((unused)) dmalloc_visit_svalue (struct svalue *s,
 								 int ref_type, void *extra, char *l)
 {
   int t = TYPEOF(*s);
@@ -725,7 +725,7 @@ static INLINE void __attribute__((unused)) dmalloc_visit_svalue (struct svalue *
   dmalloc_visit_svalue ((S), (REF_TYPE), (EXTRA), DMALLOC_LOCATION())
 #else
 #define visit_svalues real_visit_svalues
-static INLINE void __attribute__((unused)) visit_svalue (struct svalue *s, int ref_type, void *extra)
+static INLINE void ATTRIBUTE((unused)) visit_svalue (struct svalue *s, int ref_type, void *extra)
 {
   int t = TYPEOF(*s);
   check_svalue (s);
diff --git a/src/multiset.h b/src/multiset.h
index f25c294936654df25ea41c0a05e728d2fbe10b64..4b07ca425a9aab51c591a9f9558f5f7c42e04375 100644
--- a/src/multiset.h
+++ b/src/multiset.h
@@ -146,7 +146,7 @@ PMOD_EXPORT void multiset_clear_node_refs (struct multiset *l);
 
 #ifdef PIKE_DEBUG
 /* To get good type checking. */
-static INLINE union msnode __attribute__((unused)) *msnode_check (union msnode *x)
+static INLINE union msnode ATTRIBUTE((unused)) *msnode_check (union msnode *x)
   {return x;}
 PMOD_EXPORT extern const char msg_no_multiset_flag_marker[];
 #else
diff --git a/src/pike_float.h b/src/pike_float.h
index 2e16812928bf756e7747e86a11a91f8415472249..65b4ec2bacaa8160fd6b2dc68ba6712cd7eeaad7 100644
--- a/src/pike_float.h
+++ b/src/pike_float.h
@@ -33,7 +33,7 @@
 #define PIKE_ISNAN(X)	_isnan(X)
 #else /* !HAVE__ISNAN */
 /* Fallback function */
-static INLINE int __attribute__((unused)) pike_isnan(double x)
+static INLINE int ATTRIBUTE((unused)) pike_isnan(double x)
 {
   return ((x == 0.0) == (x < 0.0)) &&
     ((x == 0.0) == (x > 0.0));
diff --git a/src/program.h b/src/program.h
index 5a3d6d6d13b5358fc3ff5dd6f35c3e02f8923d54..7b29464e0b8c5ca199181b8c50146ae67ca7b501 100644
--- a/src/program.h
+++ b/src/program.h
@@ -648,7 +648,7 @@ struct program
 
 PMOD_EXPORT void dump_program_tables (const struct program *p, int indent);
 #ifdef PIKE_DEBUG
-static INLINE int __attribute__((unused)) CHECK_IDREF_RANGE (int x, const struct program *p)
+static INLINE int ATTRIBUTE((unused)) CHECK_IDREF_RANGE (int x, const struct program *p)
 {
   if (x < 0 || x >= p->num_identifier_references) {
     dump_program_tables(p, 4);
@@ -1076,7 +1076,7 @@ void make_area_executable (char *start, size_t len);
 void make_program_executable(struct program *p);
 /* Prototypes end here */
 
-static INLINE int __attribute__((unused)) FIND_LFUN(struct program * p, int lfun) {
+static INLINE int ATTRIBUTE((unused)) FIND_LFUN(struct program * p, int lfun) {
 #ifdef PIKE_DEBUG
     dmalloc_touch(struct program*, p);
     if (lfun < 0) return find_lfun_fatal(p, lfun);
diff --git a/src/rbtree.h b/src/rbtree.h
index c5a40132f00bd2708f538b4123e8742aad5c88ef..b1b0e88fefea82be648a038c00ca23846e295803 100644
--- a/src/rbtree.h
+++ b/src/rbtree.h
@@ -91,7 +91,7 @@ PMOD_EXPORT struct rb_node_hdr *rb_link_next (struct rb_node_hdr *node);
 
 #ifdef PIKE_DEBUG
 /* To get good type checking. */
-static INLINE struct rb_node_hdr __attribute__((unused)) *rb_node_check (struct rb_node_hdr *node)
+static INLINE struct rb_node_hdr ATTRIBUTE((unused)) *rb_node_check (struct rb_node_hdr *node)
   {return node;}
 #else
 #define rb_node_check(node) ((struct rb_node_hdr *) (node))
diff --git a/src/siphash24.c b/src/siphash24.c
index 23c3bfc1935740aba8b4202d2403f2cb61b4b795..88fd84c477010787e05874ddd8c9d7cd4b77bcde 100644
--- a/src/siphash24.c
+++ b/src/siphash24.c
@@ -50,9 +50,9 @@
 
 /* SipHash-2-4 */
 #ifdef __i386__
-__attribute__((fastcall))
+ATTRIBUTE((fastcall))
 #endif
-__attribute__((hot))
+ATTRIBUTE((hot))
 static size_t low_hashmem_siphash24( const void *s, size_t len, size_t nbytes, size_t key )
 {
   const unsigned char * in = (const unsigned char*)s;
diff --git a/src/stack_allocator.h b/src/stack_allocator.h
index 30c8ff2d53468ea4319edde4d4b0495c05536dab..6056d671438da6e0107cb8e0b87f59394ff4b5b3 100644
--- a/src/stack_allocator.h
+++ b/src/stack_allocator.h
@@ -15,7 +15,7 @@ struct chunk {
 void stack_alloc_enlarge(struct stack_allocator * a, size_t size);
 void stack_alloc_destroy(struct stack_allocator * a);
 
-static void __attribute__((unused)) stack_alloc_init(struct stack_allocator * a, size_t initial) {
+static void ATTRIBUTE((unused)) stack_alloc_init(struct stack_allocator * a, size_t initial) {
     a->cur = NULL;
     a->initial = initial;
 }
@@ -40,7 +40,7 @@ static void * sa_alloc_fast(struct stack_allocator * a, size_t size) {
 }
 
 MALLOC_FUNCTION
-static void __attribute__((unused)) * sa_alloc(struct stack_allocator * a, size_t size) {
+static void ATTRIBUTE((unused)) * sa_alloc(struct stack_allocator * a, size_t size) {
     sa_alloc_enlarge(a, size);
     return sa_alloc_fast(a, size);
 }
diff --git a/src/svalue.h b/src/svalue.h
index 144f0a3b5e87f0c52ebfb9a01f8368f7d49c24d1..f453af2a275f117770505200cafef01399cd1707 100644
--- a/src/svalue.h
+++ b/src/svalue.h
@@ -547,20 +547,20 @@ if(REFCOUNTED_TYPE(T) && (S)->refs && (S)->refs[0] <= 0) {\
   debug_check_type_hint ((SVALS), (NUM), (TYPE_HINT))
 
 #ifdef DEBUG_MALLOC
-static INLINE struct svalue __attribute__((unused)) *dmalloc_check_svalue(struct svalue *s, char *l)
+static INLINE struct svalue ATTRIBUTE((unused)) *dmalloc_check_svalue(struct svalue *s, char *l)
 {
   if(s && REFCOUNTED_TYPE(TYPEOF(*s)))
     debug_malloc_update_location(s->u.refs,l);
   return s;
 }
 
-static INLINE struct svalue __attribute__((unused)) *dmalloc_check_svalues(struct svalue *s, size_t num, char *l)
+static INLINE struct svalue ATTRIBUTE((unused)) *dmalloc_check_svalues(struct svalue *s, size_t num, char *l)
 {
   while (num--) dmalloc_check_svalue (s + num, l);
   return s;
 }
 
-static INLINE union anything __attribute__((unused)) *dmalloc_check_union(union anything *u,int type, char * l)
+static INLINE union anything ATTRIBUTE((unused)) *dmalloc_check_union(union anything *u,int type, char * l)
 {
   if(u && REFCOUNTED_TYPE(type))
     debug_malloc_update_location(u->refs,l);
@@ -579,14 +579,14 @@ static INLINE union anything __attribute__((unused)) *dmalloc_check_union(union
 #endif	/* !DEBUG_MALLOC */
 
 /* To be used for type checking in macros. */
-static INLINE struct array __attribute__((unused)) *pass_array (struct array *a) {return a;}
-static INLINE struct mapping __attribute__((unused)) *pass_mapping (struct mapping *m) {return m;}
-static INLINE struct multiset __attribute__((unused)) *pass_multiset (struct multiset *l) {return l;}
-static INLINE struct object __attribute__((unused)) *pass_object (struct object *o) {return o;}
-static INLINE struct program __attribute__((unused)) *pass_program (struct program *p) {return p;}
-static INLINE struct pike_string __attribute__((unused)) *pass_string (struct pike_string *s) {return s;}
-static INLINE struct pike_type __attribute__((unused)) *pass_type (struct pike_type *t) {return t;}
-static INLINE struct callable __attribute__((unused)) *pass_callable (struct callable *c) {return c;}
+static INLINE struct array ATTRIBUTE((unused)) *pass_array (struct array *a) {return a;}
+static INLINE struct mapping ATTRIBUTE((unused)) *pass_mapping (struct mapping *m) {return m;}
+static INLINE struct multiset ATTRIBUTE((unused)) *pass_multiset (struct multiset *l) {return l;}
+static INLINE struct object ATTRIBUTE((unused)) *pass_object (struct object *o) {return o;}
+static INLINE struct program ATTRIBUTE((unused)) *pass_program (struct program *p) {return p;}
+static INLINE struct pike_string ATTRIBUTE((unused)) *pass_string (struct pike_string *s) {return s;}
+static INLINE struct pike_type ATTRIBUTE((unused)) *pass_type (struct pike_type *t) {return t;}
+static INLINE struct callable ATTRIBUTE((unused)) *pass_callable (struct callable *c) {return c;}
 
 #else  /* !PIKE_DEBUG */
 
@@ -856,7 +856,7 @@ int svalues_are_constant(const struct svalue *s,
 			 TYPE_FIELD hint,
 			 struct processing *p);
 
-static INLINE TYPE_FIELD __attribute__((unused)) BITOF(struct svalue sv) {
+static INLINE TYPE_FIELD ATTRIBUTE((unused)) BITOF(struct svalue sv) {
     if (TYPEOF(sv) >= sizeof(TYPE_FIELD) * 8) {
         return BIT_MIXED | BIT_UNFINISHED;
     }
@@ -879,10 +879,10 @@ static INLINE TYPE_FIELD __attribute__((unused)) BITOF(struct svalue sv) {
   } while (0)
 
 #ifdef DEBUG_MALLOC
-static INLINE TYPE_FIELD __attribute__((unused)) dmalloc_gc_mark_svalues (struct svalue *s, size_t num, char *l)
+static INLINE TYPE_FIELD ATTRIBUTE((unused)) dmalloc_gc_mark_svalues (struct svalue *s, size_t num, char *l)
   {return real_gc_mark_svalues (dmalloc_check_svalues (s, num, l), num);}
 #define gc_mark_svalues(S, NUM) dmalloc_gc_mark_svalues ((S), (NUM), DMALLOC_LOCATION())
-static INLINE TYPE_FIELD __attribute__((unused)) dmalloc_gc_cycle_check_svalues (struct svalue *s, size_t num, char *l)
+static INLINE TYPE_FIELD ATTRIBUTE((unused)) dmalloc_gc_cycle_check_svalues (struct svalue *s, size_t num, char *l)
   {return real_gc_cycle_check_svalues (dmalloc_check_svalues (s, num, l), num);}
 #define gc_cycle_check_svalues(S, NUM) dmalloc_gc_cycle_check_svalues ((S), (NUM), DMALLOC_LOCATION())
 #else