$ man memcpy
MEMCPY(3) Linux Programmer's Manual MEMCPY(3)
NAME
memcpy - copy memory area
SYNOPSIS
#include <string.h>
Why the fuck is memcpy in string.h? It is not exclusively for dealing with strings, shouldn't it be with malloc, exit & co. in stdlib.h?
I'm aware that this is because of the ISO specification, and that it is probably like this for historical reasons, but what are those historical reasons?
You'll have to dig up the C89 committee's minutes to be certain, the C99 Rationale document says memcpy, memset, memcmp, and memchr were adopted in C89 from several existing implementations. The general goal was to provide equivalent capabilities for three types of byte sequences:
* null-terminated strings (str-).
* null-terminated strings with a maximum length (strn-).
* transparent data of specified length (mem-).
I imagine it is largely due to the implementations having enough similarities that they were originally lumped into the same sources, and thus the same header.
Name:
Anonymous2013-05-25 19:21
Yes, it's in string.h but it's also part of the kernel interface.
$ man -s 9f memcpy
Kernel Functions for Drivers memchr(9F)
NAME
memchr, memcmp, memcpy, memmove, memset - Memory operations
SYNOPSIS
#include <sys/ddi.h>
void *memchr(const void *s, int c, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);
>>7
The kernel has a private version, but it's not part of the kernel interface - a user-mode program can't call the kernel memcpy.
Name:
Anonymous2013-05-25 22:27
>>6
That sounds reasonable, but I don't actually know where to find the records of the C89 committee. Do you know where I should look?
Name:
tdavis2013-05-25 22:32
The two most sacred and defining features of TempleOS are being ring-0-only and
being identity-mapped. Linux wants to be a secure, multi-user mainframe.
That's the vision for Linux. That's why it has file permissions. The vision
for TempleOS is a modern, 64-bit Commodore 64. The C64 was a home computer
mostly used for games. It trained my generation how to program. It was simple,
open and hackable. It was not networked. The games were not multimedia works
of art, but generated programmatically with innocent, programmer (non-artist)
quality graphics. It was simple and unsecure. If you don't have malware and
you don't have bugs, protection just slows things down and makes the code
complicated.
>>9
Just ask Lambda, if he ever decides to make a peep on the matter, maybe this is something in C he's ashamed of.
Name:
L. A. Calculus!!wKyoNUUHDOmjW7I2013-05-26 5:59
DOSE FUCKERS WANTED TO PUT strto* IN stdlib.h BAK WEN I WAS IN CHARGE OF SHIT. I TOLD DEM FUCKIN MATH BOYS TO SHOVE IT UP DER ASSES AND PISS OFF.
I WANT FUCKING strerror OUT.
I WANT FUCKING strxfrm OUT.
I WANT FUCKING strcoll OUT.
U WANNA KNO WHY DA mem* FUNCTIONS ARE IN string.h? WELL SO DO I. BACK WHEN I WAS IN DA PICTURE WE PUT DAT SHIT IN memory.h AND DAT WAS DA PROPER FUCKIN WAY TO DO IT. C89'S WHERE SHIT STARTED TO GET STUPID, I'LL TELL YA DAT FUCKIN MUCH.
U WANT DA MINUTES? WELL, I DON'T HAVE 'EM, BUT HERE'S DA FUCKIN' HIGHLIGHT OF 'EM:
SOMETHING-O-CLOCK NINETEEN EIGHTY FUCK: Lambda Arthur Calculus, angered after a heated argument, gets up on his desk, drops his pants to his ankles, and defecates on his copy of the current draft. Everyone else makes stupid, repulsed sounds as they hurry out of the room like little school girls. Lambda Arthur Calculus, then standing up, shouts out after them: "DATS WAT I THINK OF UR STANDARD U FUCKIN RETOIDS."
SOMETHING-O-CLOCK NINETEEN EIGHTY FUCK (minutes later): Some toilet scrubbers clean up the mess and the room is aired out. Meanwhile, in the corridor outside the room, Lambda Arthur Calculus is kicked off the committee and C begins its horrible turn for the worse.
Name:
Anonymous2013-05-26 6:18
>>9
Nope. You could try asking in comp.lang.c or comp.lang.c.moderated, I bet some of the original committee members are still around.
Name:
Anonymous2013-05-26 6:29
>>9
Actually, the Rationale document refers to an earlier library standard, "/usr/group Standard" from 1984.
#ifndef _STRING_H
# include <string.h>
#endif /* string.h */
#endif /* memory.h */
How the mighty have fallen.
Name:
Anonymous2013-05-26 15:08
>>21 $ cat /usr/include/memory.h
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)memory.h 8.1 (Berkeley) 6/2/93
*/
#include <string.h>
Name:
Anonymous2013-05-27 7:03
>>21,22
WAT FUCKIN SHITTY C LIBRARIES R U CUNTS LOOKIN' AT?
BACK IN MY DAY WE KEPT memory.h SEPARATE FROM string.h 'CAUSE BACK IN DOSE DAYS PROGRAMMERS WEREN'T GIRLY RETOIDS WHO WERE SCARED OF POOP. WE DID SHIT. WE DIDN'T SIT AROUND ALL DAY LIKE A BUNCH OF GIRLS, DRINKING TEA, AND WRITING FANCY SCHMANCY MATH BOY STANDARDS LIKE DA ONES YA SEE TODAY.
>>26
WAT DA FUCK IS DIS C++ SHIT? UR HURTING MY EYES. N WAT FUCKIN RETOID DECIDED TO PROVIDE memccpy? DAT SHIT MUSTA BEEN WRITTEN BY A BUNCH OF RETOIDS. HERE'S MY VERSION:
memory.h:
void *memchr(const void *v, int c, size_t n);
int memcmp(const void *a, const void *b, size_t n);
WATS DA MADDA? U RETOIDS NEVER SEEN A HEADER FILE WITHOUT UR STUPID HEADER GUARDS? DATS COS UR A BUNCH OF MESSY RETOIDS WHO DONT KNO HOW TO #include FILES.
>>30
I WROTE DAT RITE NOW U FUCKIN RETOID. BACK WEN I WAS 12 DOSE FUNCTIONS TOOK AND RETURNED A FUCKIN char *. DER WAS NO size_t EITHER, WE USED A FUCKIN int YA RETOID.
MAYBE I'LL MAKE ANOTHER CHALLENGE THREAD, HUH? HOW WOULD U FUKIN RETOIDS LIKE DAT?
ANY OF U RETOIDS RED DA STANDARD YET? IS THIS SHIT STILL FILLED WITH MATH BOYS AND THEIR WIENY GAMMA FUNCTIONS? WAT ABOUT SISSY FATASSES WITH A LOT OF BABY FAT WHO BURST INTO TEARS WHEN YOU GIVE 'EM A CHALLENGE DATS TOO HARD FOR EM, THEN RESPOND BY SPAMMING YOUR THREAD LIKE AN IMMATURE RETOID?
Name:
Anonymous2013-05-27 13:34
I'LL CONSUME DIS BOARD LIKE MONO CONSUMES UR HARD DISK AND UR FUCKIN CPU CYCLES.
Name:
Anonymous2013-05-27 13:36
NOT TO MENTION UR FUCKIN RAM. DATS WAT MONO DOES, CONSUMES SHIT. IT'S A LOAD OF CRAP 'CAUSE IT WAS WRITTEN BY SOME PUSSY CHRISTIAN WHO THINKS SOME RETOID'S GONNA SAVE HIM. NOT MY FUCKING STYLE. YOU WANNA BE SAVED? YOU REED DA FUKIN STANDARD.
AND U CAN PUT DAT ON MY FUCKIN TOMBSTONE, U FUKIN RETOID.