Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: torek@elf.bsdi.com (Chris Torek)
Subject: Re: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA *
Date: 1998/08/30	[thread overview]
Message-ID: <6scnqc$ilb@elf.bsdi.com> (raw)
In-Reply-To: 35E9DAA0.8097B24F@videotron.ca

In article <35E9DAA0.8097B24F@videotron.ca> JF Mezei
<jfmezei.spamnot@videotron.ca> wrote:
>There is no difference between a library call and a user-written
>function.  I once worked on a project where a hacker had created
>his own libraries that redefined all the standard C routines ...

No difference?

	% cat >foo.c
	#include <string.h>
	void *memory_copy(void *dst, const void *src, size_t len);

	void f1(int *dst, int *src) {
		memcpy(dst, src, sizeof *dst);
	}

	void f2(int *dst, int *src) {
		memory_copy(dst, src, sizeof *dst);
	}
	% cc -S -O2 foo.c -fomit-frame-pointer
		.file	"foo.c"
		.version	"01.01"
	gcc2_compiled.:
	.text
		.align 4
	.globl f1
		.type	 f1,@function
	f1:
		movl 4(%esp),%eax
		movl 8(%esp),%edx
		movl (%edx),%edx
		movl %edx,(%eax)
		ret
	.Lfe1:
		.size	 f1,.Lfe1-f1
		.align 4
	.globl f2
		.type	 f2,@function
	f2:
		pushl $4
		pushl 12(%esp)
		pushl 12(%esp)
		call memory_copy
		addl $12,%esp
		ret
	.Lfe2:
		.size	 f2,.Lfe2-f2
		.ident	"GCC: (GNU) 2.7.2.1"
	%

If there is no difference between a call to memcpy and a call to
memory_copy, why is it that f2() contains a call, but f1() does
not?  And if I did attempt to subvert memcpy(), when would my
memcpy() get called, vs the implementation's?

Does this compiler inline calls to printf() in the same way it
inlines calls to memcpy()?  How do you know?  (*I* know, because
I have to work on this compiler now and then.  You could obtain
the source for GCC 2.7.2.1 and read it, but how will you know
what changes I may have made?)
-- 
In-Real-Life: Chris Torek, Berkeley Software Design Inc
El Cerrito, CA	Domain:	torek@bsdi.com	+1 510 234 3167
Antispam notice: unsolicited commercial email will be handled at my
consulting rate; pyramid-scheme mail will be forwarded to the FTC.



  reply	other threads:[~1998-08-30  4:00 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0095000017115526000002L062*@MHS>
     [not found] ` <35E04DF1.1911@world.std.com>
     [not found]   ` <35E09E76.6773@earthlink.net>
1998-08-23  4:00     ` Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Terry C. Shannon
1998-08-23  4:00       ` Glenn C. Everhart
1998-08-24  4:00         ` Paul Sture
1998-08-25  4:00           ` Gregg E Economou
1998-08-25  4:00             ` Jordan Henderson
1998-08-26  4:00               ` Bob Koehler
     [not found]                 ` <6s910k$2bo$1@Starbase.NeoSoft.COM>
     [not found]                   ` <35e833be.0@news.wizvax.net>
1998-08-29  4:00                     ` Jordan Henderson
1998-08-30  4:00                       ` John Wilson
1998-08-30  4:00                         ` JF Mezei
1998-08-30  4:00                           ` Chris Torek [this message]
1998-08-31  4:00                             ` Gregg E Economou
1998-08-31  4:00                               ` Chris Torek
1998-08-30  4:00                         ` Lawrence Kirby
1998-08-30  4:00                           ` JF Mezei
1998-08-30  4:00                             ` Martin Ambuhl
     [not found]                             ` <6scur7$qtk@bgtnsc02.wo <35EA0E22.C59E9476@videotron.ca>
1998-08-31  4:00                               ` Will Rose
1998-08-31  4:00                             ` Michael Rubenstein
1998-08-31  4:00                             ` Craig Franck
1998-08-30  4:00                               ` JF Mezei
1998-08-31  4:00                                 ` firewind
1998-09-04  4:00                         ` Thor Lancelot Simon
1998-08-30  4:00                       ` Gregg E Economou
1998-08-30  4:00                         ` K&R fight over ketchup (was: Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA ) Clint Comes
1998-08-31  4:00                           ` Bob Koehler
1998-09-05  4:00                             ` Gregg E Economou
1998-09-05  4:00                       ` Compaq prefers Alpha over Merced! BUT OF COURSE, ALPHA * Peter da Silva
1998-09-05  4:00                         ` Jordan Henderson
1998-09-07  4:00                           ` Peter da Silva
1998-09-07  4:00                             ` Jordan Henderson
1998-09-07  4:00                               ` Richard Stamp
1998-09-07  4:00                               ` Dan Pop
1998-09-07  4:00                               ` Peter da Silva
1998-09-07  4:00                                 ` Jordan Henderson
1998-09-08  4:00                                   ` JF Mezei
1998-09-08  4:00                                   ` Peter da Silva
     [not found]                                     ` <6t2im5$mke@espresso.cafe.net>
1998-09-08  4:00                                       ` Peter da Silva
1998-09-08  4:00                                     ` Peter da Silva
1998-09-08  4:00                                   ` Tim Shoppa
     [not found]                                     ` <6t4cui$hfu@espresso.cafe.net>
1998-09-09  4:00                                       ` Tim Shoppa
1998-09-08  4:00                                         ` JF Mezei
1998-09-09  4:00                                         ` Dan Pop
1998-09-09  4:00                                           ` Peter da Silva
1998-09-08  4:00                                 ` Dan Pop
1998-09-08  4:00                                   ` Peter da Silva
1998-09-08  4:00                                     ` Dan Pop
1998-08-29  4:00                   ` Gregg E Economou
1998-08-30  4:00                     ` Jay Maynard
1998-08-25  4:00             ` John Wilson
1998-08-26  4:00               ` Gregg E Economou
1998-08-27  4:00                 ` John Wilson
1998-08-26  4:00             ` Bob Koehler
1998-08-27  4:00               ` Peter da Silva
1998-08-31  4:00                 ` Boris
1998-08-27  4:00               ` Thor Lancelot Simon
1998-08-28  4:00                 ` Bob Koehler
1998-09-05  4:00                   ` Peter da Silva
1998-09-08  4:00                     ` Carl Perkins
1998-08-28  4:00                 ` TERENCE MURPHY
1998-08-28  4:00                   ` Monty Brandenberg
1998-08-28  4:00                   ` Greg Thomas
1998-08-29  4:00                     ` mathog
1998-09-01  4:00                       ` Greg Thomas
1998-08-28  4:00                   ` George Cornelius
1998-08-29  4:00                   ` Gregg E Economou
1998-09-05  4:00                   ` Peter da Silva
1998-08-31  4:00                 ` Boris
1998-08-26  4:00             ` Paul Sture
1998-08-27  4:00               ` Gregg E Economou
1998-08-28  4:00                 ` Paul Sture
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox