Fix repo format on x86_64 by using uint32_t instead of unsigned long
authorDan Winship <danw@gnome.org>
Mon Feb 04 10:46:29 2008 -0500 (2008-02-04)
changeset 108340d92912f49
parent 107 38f78baf0be9
child 109 313b0a615c14
Fix repo format on x86_64 by using uint32_t instead of unsigned long
razor.c
     1.1 --- a/razor.c	Mon Feb 04 10:12:04 2008 -0500
     1.2 +++ b/razor.c	Mon Feb 04 10:46:29 2008 -0500
     1.3 @@ -2,6 +2,7 @@
     1.4  
     1.5  #include <stdlib.h>
     1.6  #include <stddef.h>
     1.7 +#include <stdint.h>
     1.8  #include <stdio.h>
     1.9  #include <string.h>
    1.10  #include <sys/types.h>
    1.11 @@ -22,14 +23,14 @@
    1.12  };
    1.13  
    1.14  struct razor_set_section {
    1.15 -	unsigned int type;
    1.16 -	unsigned int offset;
    1.17 -	unsigned int size;
    1.18 +	uint32_t type;
    1.19 +	uint32_t offset;
    1.20 +	uint32_t size;
    1.21  };
    1.22  
    1.23  struct razor_set_header {
    1.24 -	unsigned int magic;
    1.25 -	unsigned int version;
    1.26 +	uint32_t magic;
    1.27 +	uint32_t version;
    1.28  	struct razor_set_section sections[0];
    1.29  };
    1.30  
    1.31 @@ -49,22 +50,22 @@
    1.32  #define RAZOR_FILE_POOL		6
    1.33  
    1.34  struct razor_package {
    1.35 -	unsigned long name;
    1.36 -	unsigned long version;
    1.37 -	unsigned long properties;
    1.38 -	unsigned long files;
    1.39 +	uint32_t name;
    1.40 +	uint32_t version;
    1.41 +	uint32_t properties;
    1.42 +	uint32_t files;
    1.43  };
    1.44  
    1.45  struct razor_property {
    1.46 -	unsigned long name;
    1.47 -	unsigned long version;
    1.48 -	unsigned long packages;
    1.49 +	uint32_t name;
    1.50 +	uint32_t version;
    1.51 +	uint32_t packages;
    1.52  };
    1.53  
    1.54  struct razor_entry {
    1.55 -	unsigned long name;
    1.56 -	unsigned long start;
    1.57 -	unsigned long packages;
    1.58 +	uint32_t name;
    1.59 +	uint32_t start;
    1.60 +	uint32_t packages;
    1.61  };
    1.62  
    1.63  struct razor_set {
    1.64 @@ -79,12 +80,12 @@
    1.65  };
    1.66  
    1.67  struct import_entry {
    1.68 -	unsigned long package;
    1.69 +	uint32_t package;
    1.70  	char *name;
    1.71  };
    1.72  
    1.73  struct import_directory {
    1.74 -	unsigned long name, count;
    1.75 +	uint32_t name, count;
    1.76  	struct array files;
    1.77  	struct array packages;
    1.78  	struct import_directory *last;
    1.79 @@ -232,7 +233,7 @@
    1.80  	char data[4096];
    1.81  	struct razor_set_header *header = (struct razor_set_header *) data;
    1.82  	struct array *a;
    1.83 -	unsigned long offset;
    1.84 +	uint32_t offset;
    1.85  	int i, fd;
    1.86  
    1.87  	memset(data, 0, sizeof data);
    1.88 @@ -283,16 +284,16 @@
    1.89  	return hash;
    1.90  }
    1.91  
    1.92 -static unsigned long
    1.93 +static uint32_t
    1.94  hashtable_lookup(struct hashtable *table, const char *key)
    1.95  {
    1.96  	unsigned int mask, start, i;
    1.97 -	unsigned long *b;
    1.98 +	uint32_t *b;
    1.99  	char *pool;
   1.100  
   1.101  	pool = table->pool->data;
   1.102  	mask = table->buckets.alloc - 1;
   1.103 -	start = hash_string(key) * sizeof(unsigned long);
   1.104 +	start = hash_string(key) * sizeof(uint32_t);
   1.105  
   1.106  	for (i = 0; i < table->buckets.alloc; i += sizeof *b) {
   1.107  		b = table->buckets.data + ((start + i) & mask);
   1.108 @@ -307,7 +308,7 @@
   1.109  	return 0;
   1.110  }
   1.111  
   1.112 -static unsigned long
   1.113 +static uint32_t
   1.114  add_to_string_pool(struct hashtable *table, const char *key)
   1.115  {
   1.116  	int len;
   1.117 @@ -320,33 +321,33 @@
   1.118  	return p - (char *) table->pool->data;
   1.119  }
   1.120  
   1.121 -static unsigned long
   1.122 +static uint32_t
   1.123  add_to_property_pool(struct array *pool, struct array *properties)
   1.124  {
   1.125 -	unsigned long *p;
   1.126 +	uint32_t *p;
   1.127  
   1.128  	if (properties->size == 0)
   1.129  		return ~0;
   1.130  	else if (properties->size == sizeof *p)
   1.131 -		return *(unsigned long *) properties->data | RAZOR_IMMEDIATE;
   1.132 +		return *(uint32_t *) properties->data | RAZOR_IMMEDIATE;
   1.133  
   1.134  	p = array_add(pool, properties->size);
   1.135  	memcpy(p, properties->data, properties->size);
   1.136  	p[properties->size / sizeof *p - 1] |= RAZOR_IMMEDIATE;
   1.137  
   1.138 -	return p - (unsigned long *) pool->data;
   1.139 +	return p - (uint32_t *) pool->data;
   1.140  }
   1.141  
   1.142  static void
   1.143 -do_insert(struct hashtable *table, unsigned long value)
   1.144 +do_insert(struct hashtable *table, uint32_t value)
   1.145  {
   1.146  	unsigned int mask, start, i;
   1.147 -	unsigned long *b;
   1.148 +	uint32_t *b;
   1.149  	const char *key;
   1.150  
   1.151  	key = (char *) table->pool->data + value;
   1.152  	mask = table->buckets.alloc - 1;
   1.153 -	start = hash_string(key) * sizeof(unsigned long);
   1.154 +	start = hash_string(key) * sizeof(uint32_t);
   1.155  
   1.156  	for (i = 0; i < table->buckets.alloc; i += sizeof *b) {
   1.157  		b = table->buckets.data + ((start + i) & mask);
   1.158 @@ -357,10 +358,10 @@
   1.159  	}
   1.160  }
   1.161  
   1.162 -static unsigned long
   1.163 +static uint32_t
   1.164  hashtable_insert(struct hashtable *table, const char *key)
   1.165  {
   1.166 -	unsigned long value, *buckets, *b, *end;
   1.167 +	uint32_t value, *buckets, *b, *end;
   1.168  	int alloc;
   1.169  
   1.170  	alloc = table->buckets.alloc;
   1.171 @@ -396,10 +397,10 @@
   1.172  	array_release(&table->buckets);
   1.173  }
   1.174  
   1.175 -static unsigned long
   1.176 +static uint32_t
   1.177  hashtable_tokenize(struct hashtable *table, const char *string)
   1.178  {
   1.179 -	unsigned long token;
   1.180 +	uint32_t token;
   1.181  
   1.182  	if (string == NULL)
   1.183  		string = "";
   1.184 @@ -443,7 +444,7 @@
   1.185  			    enum razor_property_type type)
   1.186  {
   1.187  	struct razor_property *p;
   1.188 -	unsigned long *r;
   1.189 +	uint32_t *r;
   1.190  
   1.191  	p = array_add(&importer->set->properties, sizeof *p);
   1.192  	p->name = hashtable_tokenize(&importer->table, name) | (type << 30);
   1.193 @@ -508,11 +509,11 @@
   1.194  }
   1.195  
   1.196  static void
   1.197 -__qsort_with_data(void *base, size_t nelem, unsigned long *map,
   1.198 +__qsort_with_data(void *base, size_t nelem, uint32_t *map,
   1.199  		  struct qsort_context *ctx)
   1.200  {
   1.201  	void *p, *start, *end, *pivot;
   1.202 -	unsigned long *mp, *mstart, *mend, tmp;
   1.203 +	uint32_t *mp, *mstart, *mend, tmp;
   1.204  	int left, right, result;
   1.205  	size_t size = ctx->size;
   1.206  
   1.207 @@ -560,12 +561,12 @@
   1.208  		__qsort_with_data(end, right, mend, ctx);
   1.209  }
   1.210  
   1.211 -unsigned long *
   1.212 +uint32_t *
   1.213  qsort_with_data(void *base, size_t nelem, size_t size,
   1.214  		compare_with_data_func_t compare, void *data)
   1.215  {
   1.216  	struct qsort_context ctx;
   1.217 -	unsigned long *map;
   1.218 +	uint32_t *map;
   1.219  	int i;
   1.220  
   1.221  	if (nelem == 0)
   1.222 @@ -575,7 +576,7 @@
   1.223  	ctx.compare = compare;
   1.224  	ctx.data = data;
   1.225  
   1.226 -	map = malloc(nelem * sizeof (unsigned long));
   1.227 +	map = malloc(nelem * sizeof (uint32_t));
   1.228  	for (i = 0; i < nelem; i++)
   1.229  		map[i] = i;
   1.230  
   1.231 @@ -651,12 +652,12 @@
   1.232  			      &pool[prop2->name & RAZOR_ENTRY_MASK]);
   1.233  }
   1.234  
   1.235 -static unsigned long *
   1.236 +static uint32_t *
   1.237  uniqueify_properties(struct razor_set *set)
   1.238  {
   1.239  	struct razor_property *rp, *up, *rp_end;
   1.240  	struct array *pkgs, *p;
   1.241 -	unsigned long *map, *rmap, *r;
   1.242 +	uint32_t *map, *rmap, *r;
   1.243  	int i, count, unique;
   1.244  
   1.245  	count = set->properties.size / sizeof(struct razor_property);
   1.246 @@ -703,9 +704,9 @@
   1.247  }
   1.248  
   1.249  static void
   1.250 -remap_links(struct array *links, unsigned long *map)
   1.251 +remap_links(struct array *links, uint32_t *map)
   1.252  {
   1.253 -	unsigned long *p, *end;
   1.254 +	uint32_t *p, *end;
   1.255  
   1.256  	end = links->data + links->size;
   1.257  	for (p = links->data; p < end; p++)
   1.258 @@ -742,7 +743,7 @@
   1.259  {
   1.260  	struct import_directory *p, *end;
   1.261  	struct razor_entry *e = NULL;
   1.262 -	unsigned long s, *r;
   1.263 +	uint32_t s, *r;
   1.264  
   1.265  	p = d->files.data;
   1.266  	end = d->files.data + d->files.size;
   1.267 @@ -777,7 +778,7 @@
   1.268  }
   1.269  
   1.270  static void
   1.271 -remap_property_package_links(struct array *properties, unsigned long *rmap)
   1.272 +remap_property_package_links(struct array *properties, uint32_t *rmap)
   1.273  {
   1.274  	struct razor_property *p, *end;
   1.275  
   1.276 @@ -794,7 +795,7 @@
   1.277  	int count, i, length;
   1.278  	struct import_entry *filenames;
   1.279  	char *f, *end;
   1.280 -	unsigned long name, *r;
   1.281 +	uint32_t name, *r;
   1.282  	char dirname[256];
   1.283  	struct import_directory *d, root;
   1.284  	struct razor_entry *e;
   1.285 @@ -859,12 +860,12 @@
   1.286  }
   1.287  
   1.288  static void
   1.289 -build_package_file_lists(struct razor_set *set, unsigned long *rmap)
   1.290 +build_package_file_lists(struct razor_set *set, uint32_t *rmap)
   1.291  {
   1.292  	struct razor_package *p, *packages;
   1.293  	struct array *pkgs;
   1.294  	struct razor_entry *e, *end;
   1.295 -	unsigned long *r, *q;
   1.296 +	uint32_t *r, *q;
   1.297  	int i, count;
   1.298  
   1.299  	count = set->packages.size / sizeof *p;
   1.300 @@ -879,7 +880,7 @@
   1.301  				RAZOR_IMMEDIATE;
   1.302  			r = &e->packages;
   1.303  		} else {
   1.304 -			r = (unsigned long *) set->package_pool.data + e->packages;
   1.305 +			r = (uint32_t *) set->package_pool.data + e->packages;
   1.306  		}
   1.307  
   1.308  		while (1) {
   1.309 @@ -903,7 +904,7 @@
   1.310  razor_importer_finish(struct razor_importer *importer)
   1.311  {
   1.312  	struct razor_set *set;
   1.313 -	unsigned long *map, *rmap;
   1.314 +	uint32_t *map, *rmap;
   1.315  	int i, count;
   1.316  
   1.317  	map = uniqueify_properties(importer->set);
   1.318 @@ -938,13 +939,13 @@
   1.319  struct razor_package_iterator {
   1.320  	struct razor_set *set;
   1.321  	struct razor_package *package, *end;
   1.322 -	unsigned long *index;
   1.323 +	uint32_t *index;
   1.324  	int last;
   1.325  };
   1.326  
   1.327  struct razor_package_iterator *
   1.328  razor_package_iterator_create_with_index(struct razor_set *set,
   1.329 -					 unsigned long *index)
   1.330 +					 uint32_t *index)
   1.331  {
   1.332  	struct razor_package_iterator *pi;
   1.333  
   1.334 @@ -967,12 +968,12 @@
   1.335  razor_package_iterator_create_for_property(struct razor_set *set,
   1.336  					   struct razor_property *property)
   1.337  {
   1.338 -	unsigned long *index;
   1.339 +	uint32_t *index;
   1.340  
   1.341  	if (property->packages & RAZOR_IMMEDIATE)
   1.342  		index = &property->packages;
   1.343  	else
   1.344 -		index = (unsigned long *)
   1.345 +		index = (uint32_t *)
   1.346  			set->package_pool.data + property->packages;
   1.347  
   1.348  	return razor_package_iterator_create_with_index(set, index);
   1.349 @@ -1035,7 +1036,7 @@
   1.350  struct razor_property_iterator {
   1.351  	struct razor_set *set;
   1.352  	struct razor_property *property, *end;
   1.353 -	unsigned long *index;
   1.354 +	uint32_t *index;
   1.355  	int last;
   1.356  };
   1.357  
   1.358 @@ -1051,7 +1052,7 @@
   1.359  	pi->property = set->properties.data;
   1.360  
   1.361  	if (package)
   1.362 -		pi->index = (unsigned long *)
   1.363 +		pi->index = (uint32_t *)
   1.364  			set->property_pool.data + package->properties;
   1.365  
   1.366  	return pi;
   1.367 @@ -1166,7 +1167,7 @@
   1.368  				       const char *filename)
   1.369  {
   1.370  	struct razor_entry *entry;
   1.371 -	unsigned long *index;
   1.372 +	uint32_t *index;
   1.373  
   1.374  	entry = find_entry(set, set->files.data, filename);
   1.375  	if (entry == NULL)
   1.376 @@ -1175,19 +1176,19 @@
   1.377  	if (entry->packages & RAZOR_IMMEDIATE)
   1.378  		index = &entry->packages;
   1.379  	else
   1.380 -		index = (unsigned long *)
   1.381 +		index = (uint32_t *)
   1.382  			set->package_pool.data + entry->packages;
   1.383  
   1.384  	return razor_package_iterator_create_with_index(set, index);
   1.385  }
   1.386  
   1.387 -static unsigned long *
   1.388 -list_package_files(struct razor_set *set, unsigned long *r,
   1.389 -		   struct razor_entry *dir, unsigned long end,
   1.390 +static uint32_t *
   1.391 +list_package_files(struct razor_set *set, uint32_t *r,
   1.392 +		   struct razor_entry *dir, uint32_t end,
   1.393  		   char *prefix)
   1.394  {
   1.395  	struct razor_entry *e, *f, *entries;
   1.396 -	unsigned long next, file;
   1.397 +	uint32_t next, file;
   1.398  	char *pool;
   1.399  	int len;
   1.400  	
   1.401 @@ -1242,12 +1243,12 @@
   1.402  razor_set_list_package_files(struct razor_set *set, const char *name)
   1.403  {
   1.404  	struct razor_package *package;
   1.405 -	unsigned long *r, end;
   1.406 +	uint32_t *r, end;
   1.407  	char buffer[512];
   1.408  
   1.409  	package = razor_set_get_package(set, name);
   1.410  
   1.411 -	r = (unsigned long *) set->file_pool.data + package->files;
   1.412 +	r = (uint32_t *) set->file_pool.data + package->files;
   1.413  	end = set->files.size / sizeof (struct razor_entry);
   1.414  	buffer[0] = '\0';
   1.415  	list_package_files(set, r, set->files.data, end, buffer);
   1.416 @@ -1257,7 +1258,7 @@
   1.417  razor_set_validate(struct razor_set *set, struct array *unsatisfied)
   1.418  {
   1.419  	struct razor_property *r, *p, *end;
   1.420 -	unsigned long *u;
   1.421 +	uint32_t *u;
   1.422  	char *pool;
   1.423  
   1.424  	end = set->properties.data + set->properties.size;
   1.425 @@ -1305,7 +1306,7 @@
   1.426  {
   1.427  	struct array unsatisfied;
   1.428  	struct razor_property *properties, *r;
   1.429 -	unsigned long *u, *end;
   1.430 +	uint32_t *u, *end;
   1.431  	char *pool;
   1.432  
   1.433  	array_init(&unsatisfied);
   1.434 @@ -1334,7 +1335,7 @@
   1.435  
   1.436  struct source {
   1.437  	struct razor_set *set;
   1.438 -	unsigned long *property_map;
   1.439 +	uint32_t *property_map;
   1.440  };
   1.441  
   1.442  struct razor_merger {
   1.443 @@ -1371,10 +1372,10 @@
   1.444  static void
   1.445  add_package(struct razor_merger *merger,
   1.446  	    struct razor_package *package, struct source *source,
   1.447 -	    unsigned long flags)
   1.448 +	    uint32_t flags)
   1.449  {
   1.450  	char *pool;
   1.451 -	unsigned long *r;
   1.452 +	uint32_t *r;
   1.453  	struct razor_package *p;
   1.454  
   1.455  	pool = source->set->string_pool.data;
   1.456 @@ -1388,7 +1389,7 @@
   1.457  	if (package->properties & RAZOR_IMMEDIATE)
   1.458  		r = &package->properties;
   1.459  	else
   1.460 -		r = (unsigned long *)
   1.461 +		r = (uint32_t *)
   1.462  			source->set->property_pool.data + package->properties;
   1.463  	while (1) {
   1.464  		source->property_map[*r & RAZOR_ENTRY_MASK] = 1;
   1.465 @@ -1406,7 +1407,7 @@
   1.466  	struct razor_package *upstream_packages, *p, *s, *send;
   1.467  	struct source *source1, *source2;
   1.468  	char *spool, *upool;
   1.469 -	unsigned long *u, *uend;
   1.470 +	uint32_t *u, *uend;
   1.471  	int cmp;
   1.472  
   1.473  	source1 = &merger->source1;
   1.474 @@ -1440,7 +1441,7 @@
   1.475  	}
   1.476  }
   1.477  
   1.478 -static unsigned long
   1.479 +static uint32_t
   1.480  add_property(struct razor_merger *merger,
   1.481  	     const char *name, const char *version, int type)
   1.482  {
   1.483 @@ -1458,7 +1459,7 @@
   1.484  {
   1.485  	struct razor_property *p1, *p2;
   1.486  	struct razor_set *set1, *set2;
   1.487 -	unsigned long *map1, *map2;
   1.488 +	uint32_t *map1, *map2;
   1.489  	int i, j, cmp, count1, count2;
   1.490  	char *pool1, *pool2;
   1.491  
   1.492 @@ -1514,14 +1515,14 @@
   1.493  	}
   1.494  }
   1.495  
   1.496 -static unsigned long
   1.497 -emit_properties(struct array *source_pool, unsigned long index,
   1.498 -		unsigned long *map, struct array *pool)
   1.499 +static uint32_t
   1.500 +emit_properties(struct array *source_pool, uint32_t index,
   1.501 +		uint32_t *map, struct array *pool)
   1.502  {
   1.503 -	unsigned long r, *p, *q;
   1.504 +	uint32_t r, *p, *q;
   1.505  
   1.506  	r = pool->size / sizeof *q;
   1.507 -	p = (unsigned long *) source_pool->data + index;
   1.508 +	p = (uint32_t *) source_pool->data + index;
   1.509  	while (1) {
   1.510  		q = array_add(pool, sizeof *q);
   1.511  		*q = map[*p & RAZOR_ENTRY_MASK] | (*p & ~RAZOR_ENTRY_MASK);
   1.512 @@ -1542,7 +1543,7 @@
   1.513  	struct array *pkgs, *a;
   1.514  	struct razor_package *pkg, *pkg_end;
   1.515  	struct razor_property *prop, *prop_end;
   1.516 -	unsigned long *r, *q, *pool;
   1.517 +	uint32_t *r, *q, *pool;
   1.518  	int count;
   1.519  
   1.520  	count = set->properties.size / sizeof (struct razor_property);
   1.521 @@ -1647,7 +1648,7 @@
   1.522  {
   1.523  	struct razor_property *requires, *r;
   1.524  	struct razor_property *p, *pend;
   1.525 -	unsigned long *u, *end, *pkg, *package_pool;
   1.526 +	uint32_t *u, *end, *pkg, *package_pool;
   1.527  	char *pool, *upool;
   1.528  
   1.529  	end = unsatisfied->data + unsatisfied->size;
   1.530 @@ -1697,7 +1698,7 @@
   1.531  	struct razor_package_iterator *pi;
   1.532  	struct razor_package *p, *packages;
   1.533  	const char *name, *version;
   1.534 -	unsigned long *r;
   1.535 +	uint32_t *r;
   1.536  	int i;
   1.537  
   1.538  	packages = (struct razor_package *) set->packages.data;
   1.539 @@ -1721,7 +1722,7 @@
   1.540  		  struct razor_set *upstream, struct array *list)
   1.541  {
   1.542  	struct razor_package *p, *u, *pend, *uend;
   1.543 -	unsigned long *r;
   1.544 +	uint32_t *r;
   1.545  	char *pool, *upool;
   1.546  
   1.547  	pend = set->packages.data + set->packages.size;
   1.548 @@ -1748,7 +1749,7 @@
   1.549  	struct razor_package *upackages;
   1.550  	struct array list, unsatisfied;
   1.551  	char *pool;
   1.552 -	unsigned long *u, *end;
   1.553 +	uint32_t *u, *end;
   1.554  	int total = 0;
   1.555  
   1.556  	array_init(&list);