Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
2001-04-25  Ulrich Drepper  <drepper@redhat.com>

	* malloc/malloc.c: Allow MALLOC_ALIGNMENT to be defined on the
	compiler command line.
	* sysdeps/hppa/Makefile: Add -DMALLOC_ALIGNMENT=16 to compiler
	command line for malloc.c.
  • Loading branch information
Ulrich Drepper committed Apr 26, 2001
1 parent e0ea358 commit c3fa6e3
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 26 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2001-04-25 Ulrich Drepper <drepper@redhat.com>

* malloc/malloc.c: Allow MALLOC_ALIGNMENT to be defined on the
compiler command line.
* sysdeps/hppa/Makefile: Add -DMALLOC_ALIGNMENT=16 to compiler
command line for malloc.c.

2001-04-25 Jakub Jelinek <jakub@redhat.com>

* sysdeps/unix/sysv/linux/sparc/sparc64/bits/time.h: Move to...
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ configurations:
alpha*-*-linux-gnu Linux-2.x on DEC Alpha
powerpc-*-linux-gnu Linux and MkLinux on PowerPC systems
sparc-*-linux-gnu Linux-2.x on SPARC
sparc64-*-linux-gnu Linux-2.x on UltraSPARC
sparc64-*-linux-gnu Linux-2.x on UltraSPARC 64-bit
arm-*-none ARM standalone systems
arm-*-linux Linux-2.x on ARM
arm-*-linuxaout Linux-2.x on ARM using a.out binaries
Expand Down
5 changes: 4 additions & 1 deletion malloc/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,10 @@ static void free_atfork();
/* sizes, alignments */

#define SIZE_SZ (sizeof(INTERNAL_SIZE_T))
#define MALLOC_ALIGNMENT (SIZE_SZ + SIZE_SZ)
/* Allow the default to be overwritten on the compiler command line. */
#ifndef MALLOC_ALIGNMENT
# define MALLOC_ALIGNMENT (SIZE_SZ + SIZE_SZ)
#endif
#define MALLOC_ALIGN_MASK (MALLOC_ALIGNMENT - 1)
#define MINSIZE (sizeof(struct malloc_chunk))

Expand Down
4 changes: 4 additions & 0 deletions sysdeps/hppa/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
# CFLAGS-.os += -ffunction-sections
LDFLAGS-c_pic.os += -Wl,--unique=.text*

ifeq ($(subdir),malloc)
CFLAGS-malloc.c += -DMALLOC_ALIGNMENT=16
endif

ifeq ($(subdir),elf)
dl-routines += dl-symaddr dl-fptr
rtld-routines += dl-symaddr dl-fptr
Expand Down
47 changes: 23 additions & 24 deletions sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ __get_clockfreq_via_proc_openprom (void)
obp_fd = open ("/proc/openprom", O_RDONLY);
if (obp_fd != -1)
{
unsigned long buf[4096 / sizeof (unsigned long)];
unsigned long int buf[4096 / sizeof (unsigned long int)];
struct dirent *dirp = (struct dirent *) buf;
off_t dbase = (off_t) 0;
int len;
ssize_t len;

while ((len = getdirentries (obp_fd, (char *) dirp,
sizeof (buf), &dbase)) > 0)
Expand All @@ -103,34 +103,37 @@ __get_clockfreq_via_proc_openprom (void)
while (len > 0)
{
char node_name[strlen ("/proc/openprom/")
+ this_dirp->d_reclen
+ _D_ALLOC_NAMLEN (this_dirp)
+ strlen ("/clock-frequency")];
int fd;

strcpy (node_name, "/proc/openprom/");
strcat (node_name, this_dirp->d_name);
strcat (node_name, "/device_type");
/* Note that
strlen("/clock-frequency") > strlen("/device_type")
*/
stpcpy (stpcpy (stpcpy (node_name, "/proc/openprom/"),
this_dirp->d_name),
"/device_type");
fd = open (node_name, O_RDONLY);
if (fd != -1)
{
char type_string[128];
int ret;

ret = read (fd, type_string, sizeof (type_string));
if (ret > 0 && !strncmp (type_string, "'cpu'", 5))
if (ret > 0 && strncmp (type_string, "'cpu'", 5) == 0)
{
int clkfreq_fd;

strcpy (node_name, "/proc/openprom/");
strcat (node_name, this_dirp->d_name);
strcat (node_name, "/clock-frequency");
stpcpy (stpcpy (stpcpy (node_name, "/proc/openprom/"),
this_dirp->d_name),
"/clock-frequency");
clkfreq_fd = open (node_name, O_RDONLY);
if (fd != -1)
{
if (read (clkfreq_fd, type_string,
sizeof (type_string)) > 0)
result = (hp_timing_t)
strtol (type_string, (char **)NULL, 16);
strtoull (type_string, NULL, 16);
close (clkfreq_fd);
}
}
Expand All @@ -142,7 +145,7 @@ __get_clockfreq_via_proc_openprom (void)

len -= this_dirp->d_reclen;
this_dirp = (struct dirent *)
((char *)this_dirp + this_dirp->d_reclen);
((char *) this_dirp + this_dirp->d_reclen);
}
if (result != 0)
break;
Expand Down Expand Up @@ -170,31 +173,30 @@ __get_clockfreq_via_dev_openprom (void)

obp_cmd->oprom_size =
sizeof (obp_buf) - sizeof (unsigned int);
*(int *)obp_cmd->oprom_array = 0;
*(int *) obp_cmd->oprom_array = 0;
ret = ioctl (obp_dev_fd, OPROMCHILD, (char *) obp_cmd);
if (ret == 0)
{
int cur_node = *(int *)obp_cmd->oprom_array;
int cur_node = *(int *) obp_cmd->oprom_array;

while (cur_node != 0 && cur_node != -1)
{
obp_cmd->oprom_size = sizeof (obp_buf) - sizeof (unsigned int);
strcpy (obp_cmd->oprom_array, "device_type");
ret = ioctl (obp_dev_fd, OPROMGETPROP, (char *) obp_cmd);
if (ret == 0
&& !strncmp (obp_cmd->oprom_array, "cpu", 3))
&& strncmp (obp_cmd->oprom_array, "cpu", 3) == 0)
{
obp_cmd->oprom_size = sizeof (obp_buf) - sizeof (unsigned int);
obp_cmd->oprom_size = (sizeof (obp_buf)
- sizeof (unsigned int));
strcpy (obp_cmd->oprom_array, "clock-frequency");
ret = ioctl (obp_dev_fd, OPROMGETPROP, (char *) obp_cmd);
if (ret == 0)
{
result = (hp_timing_t)
*(unsigned int *)obp_cmd->oprom_array;
}
result =
(hp_timing_t) *(unsigned int *) obp_cmd->oprom_array;
}
obp_cmd->oprom_size = sizeof (obp_buf) - sizeof (unsigned int);
*(int *)obp_cmd->oprom_array = cur_node;
*(int *) obp_cmd->oprom_array = cur_node;
ret = ioctl (obp_dev_fd, OPROMNEXT, (char *) obp_cmd);
if (ret < 0)
break;
Expand All @@ -219,21 +221,18 @@ __get_clockfreq (void)
It contains at least one line like
Cpu0ClkTick : 000000002cb41780
We search for this line and convert the number in an integer. */

result = __get_clockfreq_via_cpuinfo ();
if (result != 0)
return result;

/* If that did not work, try to find an OpenPROM node
with device_type equal to 'cpu' using /dev/openprom
and fetch the clock-frequency property from there. */

result = __get_clockfreq_via_dev_openprom ();
if (result != 0)
return result;

/* Finally, try the same lookup as above but using /proc/openprom. */

result = __get_clockfreq_via_proc_openprom ();

return result;
Expand Down

0 comments on commit c3fa6e3

Please sign in to comment.