Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #3732 > unrolled thread
| Started by | pozz <pozzugno@gmail.com> |
|---|---|
| First post | 2011-05-11 03:01 -0700 |
| Last post | 2011-05-11 21:27 +0100 |
| Articles | 20 on this page of 62 — 21 participants |
Back to article view | Back to comp.lang.c
Passing an integer to a function that accepts a void pointer pozz <pozzugno@gmail.com> - 2011-05-11 03:01 -0700
Re: Passing an integer to a function that accepts a void pointer Tom St Denis <tom@iahu.ca> - 2011-05-11 03:52 -0700
Re: Passing an integer to a function that accepts a void pointer pete <pfiland@mindspring.com> - 2011-05-11 08:10 -0400
Re: Passing an integer to a function that accepts a void pointer pozz <pozzugno@gmail.com> - 2011-05-11 18:28 +0200
Re: Passing an integer to a function that accepts a void pointer Shao Miller <sha0.miller@gmail.com> - 2011-05-11 22:10 -0500
Re: Passing an integer to a function that accepts a void pointer pozz <pozzugno@gmail.com> - 2011-05-12 19:44 +0200
Re: Passing an integer to a function that accepts a void pointer Shao Miller <sha0.miller@gmail.com> - 2011-05-12 14:16 -0400
Re: Passing an integer to a function that accepts a void pointer pozz <pozzugno@gmail.com> - 2011-05-12 21:21 +0200
Re: Passing an integer to a function that accepts a void pointer Shao Miller <sha0.miller@gmail.com> - 2011-05-12 16:05 -0400
Re: Passing an integer to a function that accepts a void pointer pozz <pozzugno@gmail.com> - 2011-05-13 23:39 +0200
Re: Passing an integer to a function that accepts a void pointer Dr Nick <3-nospam@temporary-address.org.uk> - 2011-05-14 09:41 +0100
Re: Passing an integer to a function that accepts a void pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-12 22:07 -0400
Re: Passing an integer to a function that accepts a void pointer pozz <pozzugno@gmail.com> - 2011-05-13 23:12 +0200
Re: Passing an integer to a function that accepts a void pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-13 23:30 -0400
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-11 04:03 -0700
Re: Passing an integer to a function that accepts a void pointer Heikki Kallasjoki <see@end.of.message.invalid> - 2011-05-11 13:03 +0000
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-11 06:46 -0700
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-11 08:24 -0700
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-11 08:44 -0700
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-11 08:58 -0700
Re: Passing an integer to a function that accepts a void pointer gazelle@shell.xmission.com (Kenny McCormack) - 2011-05-11 17:38 +0000
Re: Passing an integer to a function that accepts a void pointer Kenneth Brody <kenbrody@spamcop.net> - 2011-05-11 14:57 -0400
Re: Passing an integer to a function that accepts a void pointer Paul N <gw7rib@aol.com> - 2011-05-11 14:06 -0700
Re: Passing an integer to a function that accepts a void pointer Michael Press <rubrum@pacbell.net> - 2011-05-12 13:59 -0700
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 14:12 -0700
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-12 15:27 -0700
Re: Passing an integer to a function that accepts a void pointer Seebs <usenet-nospam@seebs.net> - 2011-05-12 22:37 +0000
Re: Passing an integer to a function that accepts a void pointer Ian Collins <ian-news@hotmail.com> - 2011-05-13 10:41 +1200
Re: Passing an integer to a function that accepts a void pointer Shao Miller <sha0.miller@gmail.com> - 2011-05-12 17:57 -0500
Re: Passing an integer to a function that accepts a void pointer Ian Collins <ian-news@hotmail.com> - 2011-05-13 11:05 +1200
Re: Passing an integer to a function that accepts a void pointer Seebs <usenet-nospam@seebs.net> - 2011-05-12 23:19 +0000
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 16:32 -0700
Re: Passing an integer to a function that accepts a void pointer Shao Miller <sha0.miller@gmail.com> - 2011-05-12 19:13 -0500
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 18:18 -0700
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 16:18 -0700
Re: Passing an integer to a function that accepts a void pointer Tobias Blass <tobiasblass@gmx.net> - 2011-05-13 08:24 +0000
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-13 01:33 -0700
Re: Passing an integer to a function that accepts a void pointer Seebs <usenet-nospam@seebs.net> - 2011-05-13 08:36 +0000
Re: Passing an integer to a function that accepts a void pointer "madamemandm@yahoo.com" <madamemandm@yahoo.com> - 2011-05-13 07:08 -0700
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 15:59 -0700
Re: Passing an integer to a function that accepts a void pointer Seebs <usenet-nospam@seebs.net> - 2011-05-11 21:46 +0000
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-12 00:56 -0700
Re: Passing an integer to a function that accepts a void pointer Ian Collins <ian-news@hotmail.com> - 2011-05-12 20:06 +1200
Re: Passing an integer to a function that accepts a void pointer Heikki Kallasjoki <see@end.of.message.invalid> - 2011-05-12 08:59 +0000
Re: Passing an integer to a function that accepts a void pointer Ian Collins <ian-news@hotmail.com> - 2011-05-13 10:39 +1200
Re: Passing an integer to a function that accepts a void pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-12 06:51 -0400
Re: Passing an integer to a function that accepts a void pointer Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-12 04:08 -0700
Re: Passing an integer to a function that accepts a void pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-12 07:33 -0400
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 07:58 -0700
Re: Passing an integer to a function that accepts a void pointer gazelle@shell.xmission.com (Kenny McCormack) - 2011-05-12 15:23 +0000
Re: Passing an integer to a function that accepts a void pointer Shao Miller <sha0.miller@gmail.com> - 2011-05-12 13:36 -0400
Re: Passing an integer to a function that accepts a void pointer Keith Thompson <kst-u@mib.org> - 2011-05-12 12:03 -0700
Re: Passing an integer to a function that accepts a void pointer Seebs <usenet-nospam@seebs.net> - 2011-05-12 15:57 +0000
Re: Passing an integer to a function that accepts a void pointer Michael Press <rubrum@pacbell.net> - 2011-05-12 14:14 -0700
Re: Passing an integer to a function that accepts a void pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-12 22:20 -0400
Re: Passing an integer to a function that accepts a void pointer Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-14 02:39 +0100
Re: Passing an integer to a function that accepts a void pointer Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-11 07:37 -0400
Re: Passing an integer to a function that accepts a void pointer James Kuyper <jameskuyper@verizon.net> - 2011-05-11 09:42 -0400
Re: Passing an integer to a function that accepts a void pointer Datesfat Chicks <datesfat.chicks@gmail.com> - 2011-05-11 11:53 -0400
Re: Passing an integer to a function that accepts a void pointer Fred <fred.l.kleinschmidt@boeing.com> - 2011-05-11 10:44 -0700
Re: Passing an integer to a function that accepts a void pointer Datesfat Chicks <datesfat.chicks@gmail.com> - 2011-05-12 07:58 -0400
Re: Passing an integer to a function that accepts a void pointer Dr Nick <3-nospam@temporary-address.org.uk> - 2011-05-11 21:27 +0100
Page 2 of 4 — ← Prev page 1 [2] 3 4 Next page →
| From | gazelle@shell.xmission.com (Kenny McCormack) |
|---|---|
| Date | 2011-05-11 17:38 +0000 |
| Message-ID | <iqehiq$gcv$2@news.xmission.com> |
| In reply to | #3765 |
In article <lnd3jpkz4z.fsf@nuthaus.mib.org>,
Keith Thompson <kst-u@mib.org> wrote:
>Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> writes:
>> In article <lnhb91l0p9.fsf@nuthaus.mib.org>, Keith Thompson <kst-u@mib.org>
>> wrote:
>>> But how much software depends on being able to convert arbitrary
>>> integer values to pointers? Why would you even want to do that?
>>
>> Most callback interfaces designed in the last dozens of years depend on that.
>
>Can you provide a concrete example?
Yes. He can.
http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/questions-with-yes-or-no-answers.html
--
But the Bush apologists hope that you won't remember all that. And they
also have a theory, which I've been hearing more and more - namely,
that President Obama, though not yet in office or even elected, caused the
2008 slump. You see, people were worried in advance about his future
policies, and that's what caused the economy to tank. Seriously.
(Paul Krugman - Addicted to Bush)
[toc] | [prev] | [next] | [standalone]
| From | Kenneth Brody <kenbrody@spamcop.net> |
|---|---|
| Date | 2011-05-11 14:57 -0400 |
| Message-ID | <O_WdnQpqhJeVQVfQnZ2dnUVZ_v6dnZ2d@bestweb.net> |
| In reply to | #3768 |
On 5/11/2011 1:38 PM, Kenny McCormack wrote: > In article<lnd3jpkz4z.fsf@nuthaus.mib.org>, > Keith Thompson<kst-u@mib.org> wrote: [...] >> Can you provide a concrete example? > > Yes. He can. > > http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/questions-with-yes-or-no-answers.html They forgot "do you know what time it is?" -- Kenneth Brody
[toc] | [prev] | [next] | [standalone]
| From | Paul N <gw7rib@aol.com> |
|---|---|
| Date | 2011-05-11 14:06 -0700 |
| Message-ID | <9565b443-c6e3-4d63-9086-acfed53f265d@k3g2000prl.googlegroups.com> |
| In reply to | #3768 |
On May 11, 6:38 pm, gaze...@shell.xmission.com (Kenny McCormack) wrote: > In article <lnd3jpkz4z....@nuthaus.mib.org>, > Keith Thompson <ks...@mib.org> wrote: > >Can you provide a concrete example? > > Yes. He can. > > http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/questions-wi... Pah! That's only one step from actually asking the intended question. Consider the following, actually said by my mother: "I don't know whether you want to help your father." How many steps does it take to get from that to the actual meaning?
[toc] | [prev] | [next] | [standalone]
| From | Michael Press <rubrum@pacbell.net> |
|---|---|
| Date | 2011-05-12 13:59 -0700 |
| Message-ID | <rubrum-81EB42.13591412052011@news.albasani.net> |
| In reply to | #3775 |
In article <9565b443-c6e3-4d63-9086-acfed53f265d@k3g2000prl.googlegroups.com>, Paul N <gw7rib@aol.com> wrote: > On May 11, 6:38 pm, gaze...@shell.xmission.com (Kenny McCormack) > wrote: > > In article <lnd3jpkz4z....@nuthaus.mib.org>, > > Keith Thompson <ks...@mib.org> wrote: > > >Can you provide a concrete example? > > > > Yes. He can. > > > > http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/questions-wi... > > Pah! That's only one step from actually asking the intended question. > > Consider the following, actually said by my mother: > > "I don't know whether you want to help your father." > > How many steps does it take to get from that to the actual meaning? People seeking help can be helped by coaxing them into asking precise questions. Often a problem solves itself once the question is made sharp enough, eliminating the need even to ask the question in a forum. Do not underrate the benefit to the forum at large. Helping people who ask imprecise or vague questions is wearing. Answering well posed questions can be interesting in itself---the opposite of wearing. -- Michael Press
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-05-12 14:12 -0700 |
| Message-ID | <lniptfk4hl.fsf@nuthaus.mib.org> |
| In reply to | #3831 |
Michael Press <rubrum@pacbell.net> writes:
> In article
> <9565b443-c6e3-4d63-9086-acfed53f265d@k3g2000prl.googlegroups.com>,
> Paul N <gw7rib@aol.com> wrote:
>
[...]
>> > In article <lnd3jpkz4z....@nuthaus.mib.org>,
>> > Keith Thompson <ks...@mib.org> wrote:
>> > >Can you provide a concrete example?
>> >
[snip]
>>
>> Pah! That's only one step from actually asking the intended question.
>>
>> Consider the following, actually said by my mother:
>>
>> "I don't know whether you want to help your father."
>>
>> How many steps does it take to get from that to the actual meaning?
>
> People seeking help can be helped by coaxing them
> into asking precise questions. Often a problem
> solves itself once the question is made sharp enough,
> eliminating the need even to ask the question in a forum.
> Do not underrate the benefit to the forum at large.
> Helping people who ask imprecise or vague questions
> is wearing. Answering well posed questions can be
> interesting in itself---the opposite of wearing.
I'm all for precise questions, but the implicit meaning of "Can
you provide a concrete example" is clear enough to anyone who's not
deliberately trying to be difficult (as one poster in this thread,
not quoted here, clearly is).
And if the person of whom I actually asked the question, someone
posting as "Columbus sailed the ocean China Blue", wanted to take
it literally and just say "Yes", there would at least be a basis
for further discussion.
My current working hypothesis, given the lack of an actual
response, is that there are no such concrete examples, or at least
no significant ones, and that a C compiler that didn't support
converting arbitrary integer values to pointers without loss of
information wouldn't break much existing code.
There are plenty of things whose behavior is undefined, but that
C compilers can't afford to break, but I'm not convinced that this
is one of them.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> |
|---|---|
| Date | 2011-05-12 15:27 -0700 |
| Message-ID | <chine.bleu-55AB89.15275712052011@reserved-multicast-range-not-delegated.example.com> |
| In reply to | #3836 |
In article <lniptfk4hl.fsf@nuthaus.mib.org>, Keith Thompson <kst-u@mib.org>
wrote:
> My current working hypothesis, given the lack of an actual
> response, is that there are no such concrete examples, or at least
> no significant ones, and that a C compiler that didn't support
> converting arbitrary integer values to pointers without loss of
> information wouldn't break much existing code.
If you're finished digging yourself into a hole, you can start with
man brk
Otherwise feel free to dazzle your admirers with your inexperience.
--
Damn the living - It's a lovely life. I'm whoever you want me to be.
Silver silverware - Where is the love? At least I can stay in character.
Oval swimming pool - Where is the love? Annoying Usenet one post at a time.
Damn the living - It's a lovely life. In 1492....
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-05-12 22:37 +0000 |
| Message-ID | <slrnisoo45.20ng.usenet-nospam@guild.seebs.net> |
| In reply to | #3847 |
On 2011-05-12, Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> wrote: > In article <lniptfk4hl.fsf@nuthaus.mib.org>, Keith Thompson <kst-u@mib.org> > wrote: >> My current working hypothesis, given the lack of an actual >> response, is that there are no such concrete examples, or at least >> no significant ones, and that a C compiler that didn't support >> converting arbitrary integer values to pointers without loss of >> information wouldn't break much existing code. > If you're finished digging yourself into a hole, you can start with > man brk Steeeeerike one! brk()'s argument is a "void *" and is not an int, nor is it meaningful or valid to pass an int to it. The one which takes integer arguments is sbrk(). Care to try again? -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2011-05-13 10:41 +1200 |
| Message-ID | <93360hFoqoU2@mid.individual.net> |
| In reply to | #3849 |
On 05/13/11 10:37 AM, Seebs wrote: > On 2011-05-12, Columbus sailed the ocean China Blue<chine.bleu@yahoo.com> wrote: >> In article<lniptfk4hl.fsf@nuthaus.mib.org>, Keith Thompson<kst-u@mib.org> >> wrote: >>> My current working hypothesis, given the lack of an actual >>> response, is that there are no such concrete examples, or at least >>> no significant ones, and that a C compiler that didn't support >>> converting arbitrary integer values to pointers without loss of >>> information wouldn't break much existing code. > >> If you're finished digging yourself into a hole, you can start with >> man brk > > Steeeeerike one! > > brk()'s argument is a "void *" and is not an int, nor is it meaningful or > valid to pass an int to it. The one which takes integer arguments is > sbrk(). Bugger, you beat me to it! -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Shao Miller <sha0.miller@gmail.com> |
|---|---|
| Date | 2011-05-12 17:57 -0500 |
| Message-ID | <iqhojt$ldd$1@dont-email.me> |
| In reply to | #3851 |
On 5/12/2011 5:41 PM, Ian Collins wrote: > On 05/13/11 10:37 AM, Seebs wrote: >> On 2011-05-12, Columbus sailed the ocean China >> Blue<chine.bleu@yahoo.com> wrote: >>> In article<lniptfk4hl.fsf@nuthaus.mib.org>, Keith >>> Thompson<kst-u@mib.org> >>> wrote: >>>> My current working hypothesis, given the lack of an actual >>>> response, is that there are no such concrete examples, or at least >>>> no significant ones, and that a C compiler that didn't support >>>> converting arbitrary integer values to pointers without loss of >>>> information wouldn't break much existing code. >> >>> If you're finished digging yourself into a hole, you can start with >>> man brk >> >> Steeeeerike one! >> >> brk()'s argument is a "void *" and is not an int, nor is it meaningful or >> valid to pass an int to it. The one which takes integer arguments is >> sbrk(). > > Bugger, you beat me to it! > Question: If the argument to brk() is an address which will be one-past the new highest address, how do you build that pointer?
[toc] | [prev] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2011-05-13 11:05 +1200 |
| Message-ID | <9337dsFoqoU3@mid.individual.net> |
| In reply to | #3853 |
On 05/13/11 10:57 AM, Shao Miller wrote: > On 5/12/2011 5:41 PM, Ian Collins wrote: >> On 05/13/11 10:37 AM, Seebs wrote: >>> On 2011-05-12, Columbus sailed the ocean China >>> Blue<chine.bleu@yahoo.com> wrote: >>>> In article<lniptfk4hl.fsf@nuthaus.mib.org>, Keith >>>> Thompson<kst-u@mib.org> >>>> wrote: >>>>> My current working hypothesis, given the lack of an actual >>>>> response, is that there are no such concrete examples, or at least >>>>> no significant ones, and that a C compiler that didn't support >>>>> converting arbitrary integer values to pointers without loss of >>>>> information wouldn't break much existing code. >>> >>>> If you're finished digging yourself into a hole, you can start with >>>> man brk >>> >>> Steeeeerike one! >>> >>> brk()'s argument is a "void *" and is not an int, nor is it meaningful or >>> valid to pass an int to it. The one which takes integer arguments is >>> sbrk(). >> >> Bugger, you beat me to it! >> > > Question: If the argument to brk() is an address which will be one-past > the new highest address, how do you build that pointer? One past the new data segment, not the new highest address. -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-05-12 23:19 +0000 |
| Message-ID | <slrnisoqm4.233r.usenet-nospam@guild.seebs.net> |
| In reply to | #3856 |
On 2011-05-12, Ian Collins <ian-news@hotmail.com> wrote: > On 05/13/11 10:57 AM, Shao Miller wrote: >> Question: If the argument to brk() is an address which will be one-past >> the new highest address, how do you build that pointer? > One past the new data segment, not the new highest address. In any event, it's easy enough. Given a current address, "void *a", you do: char *b = a; b += 20000; a = b; you can do pointer arithmetic on a char *, and use this to generate new pointers. At no point does this process rely on the ability to pass integers to functions which expect pointers. -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-05-12 16:32 -0700 |
| Message-ID | <lnoc37ijgp.fsf@nuthaus.mib.org> |
| In reply to | #3863 |
Seebs <usenet-nospam@seebs.net> writes:
> On 2011-05-12, Ian Collins <ian-news@hotmail.com> wrote:
>> On 05/13/11 10:57 AM, Shao Miller wrote:
>>> Question: If the argument to brk() is an address which will be one-past
>>> the new highest address, how do you build that pointer?
>
>> One past the new data segment, not the new highest address.
>
> In any event, it's easy enough. Given a current address, "void *a", you
> do:
> char *b = a;
> b += 20000;
> a = b;
>
> you can do pointer arithmetic on a char *, and use this to generate new
> pointers. At no point does this process rely on the ability to pass
> integers to functions which expect pointers.
Right. Though it does make some non-portable assumptions about
address arithmetic -- assumptions that are almost certain to be
valid on any system on which brk() makes any sense.
(Note that gcc permits arithmetic on void* as if it were char*.
Code that calls brk() is likely to be so non-portable that depending
on a gcc extension may not be a problem.)
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Shao Miller <sha0.miller@gmail.com> |
|---|---|
| Date | 2011-05-12 19:13 -0500 |
| Message-ID | <iqht3i$2ts$1@dont-email.me> |
| In reply to | #3872 |
On 5/12/2011 6:32 PM, Keith Thompson wrote: > Seebs<usenet-nospam@seebs.net> writes: >> On 2011-05-12, Ian Collins<ian-news@hotmail.com> wrote: >>> On 05/13/11 10:57 AM, Shao Miller wrote: >>>> Question: If the argument to brk() is an address which will be one-past >>>> the new highest address, how do you build that pointer? >> >>> One past the new data segment, not the new highest address. >> >> In any event, it's easy enough. Given a current address, "void *a", you >> do: >> char *b = a; >> b += 20000; >> a = b; >> >> you can do pointer arithmetic on a char *, and use this to generate new >> pointers. At no point does this process rely on the ability to pass >> integers to functions which expect pointers. > > Right. Though it does make some non-portable assumptions about > address arithmetic -- assumptions that are almost certain to be > valid on any system on which brk() makes any sense. > Perhaps you are thinking of pointer arithmetic only being defined, in a standard sense, when pointing within the same array object[6.5.6p8]? > (Note that gcc permits arithmetic on void* as if it were char*. > Code that calls brk() is likely to be so non-portable that depending > on a gcc extension may not be a problem.) > Agreed. So a follow-up question: - Does anyone ever use brk() to specify an absolute address, or only to shrink/grow by some amount?
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-05-12 18:18 -0700 |
| Message-ID | <lnaaeriej4.fsf@nuthaus.mib.org> |
| In reply to | #3876 |
Shao Miller <sha0.miller@gmail.com> writes:
> On 5/12/2011 6:32 PM, Keith Thompson wrote:
>> Seebs<usenet-nospam@seebs.net> writes:
>>> On 2011-05-12, Ian Collins<ian-news@hotmail.com> wrote:
>>>> On 05/13/11 10:57 AM, Shao Miller wrote:
>>>>> Question: If the argument to brk() is an address which will be one-past
>>>>> the new highest address, how do you build that pointer?
>>>
>>>> One past the new data segment, not the new highest address.
>>>
>>> In any event, it's easy enough. Given a current address, "void *a", you
>>> do:
>>> char *b = a;
>>> b += 20000;
>>> a = b;
>>>
>>> you can do pointer arithmetic on a char *, and use this to generate new
>>> pointers. At no point does this process rely on the ability to pass
>>> integers to functions which expect pointers.
>>
>> Right. Though it does make some non-portable assumptions about
>> address arithmetic -- assumptions that are almost certain to be
>> valid on any system on which brk() makes any sense.
>>
>
> Perhaps you are thinking of pointer arithmetic only being defined, in a
> standard sense, when pointing within the same array object[6.5.6p8]?
Exactly.
[...]
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-05-12 16:18 -0700 |
| Message-ID | <lnwrhvik2r.fsf@nuthaus.mib.org> |
| In reply to | #3853 |
Shao Miller <sha0.miller@gmail.com> writes:
> On 5/12/2011 5:41 PM, Ian Collins wrote:
>> On 05/13/11 10:37 AM, Seebs wrote:
>>> On 2011-05-12, Columbus sailed the ocean China
>>> Blue<chine.bleu@yahoo.com> wrote:
>>>> In article<lniptfk4hl.fsf@nuthaus.mib.org>, Keith
>>>> Thompson<kst-u@mib.org>
>>>> wrote:
>>>>> My current working hypothesis, given the lack of an actual
>>>>> response, is that there are no such concrete examples, or at least
>>>>> no significant ones, and that a C compiler that didn't support
>>>>> converting arbitrary integer values to pointers without loss of
>>>>> information wouldn't break much existing code.
>>>
>>>> If you're finished digging yourself into a hole, you can start with
>>>> man brk
>>>
>>> Steeeeerike one!
>>>
>>> brk()'s argument is a "void *" and is not an int, nor is it meaningful or
>>> valid to pass an int to it. The one which takes integer arguments is
>>> sbrk().
>>
>> Bugger, you beat me to it!
>
> Question: If the argument to brk() is an address which will be
> one-past the new highest address, how do you build that pointer?
In some blatantly non-portable manner.
There's probably some way to get the current "break" value as
a void*. Given that value, you can add to it (by any of several
methods) and pass the result to brk(). Or you can use sbrk(), which
takes care of most of the bookkeeping for you. (Or, as the man
page recommends rather strongly, use malloc() to allocate memory.)
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Tobias Blass <tobiasblass@gmx.net> |
|---|---|
| Date | 2011-05-13 08:24 +0000 |
| Message-ID | <iqips7$bta$1@dont-email.me> |
| In reply to | #3866 |
On 2011-05-12, Keith Thompson <kst-u@mib.org> wrote: > [snip] > In some blatantly non-portable manner. > > There's probably some way to get the current "break" value as > a void*. Given that value, you can add to it (by any of several > methods) and pass the result to brk(). Or you can use sbrk(), which > takes care of most of the bookkeeping for you. (Or, as the man > page recommends rather strongly, use malloc() to allocate memory.) > If you call sbrk(0) it returns the current location of the "program break", that is the end of the process's data segment. Source: sbrk manpage
[toc] | [prev] | [next] | [standalone]
| From | Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> |
|---|---|
| Date | 2011-05-13 01:33 -0700 |
| Message-ID | <chine.bleu-B9E240.01335813052011@reserved-multicast-range-not-delegated.example.com> |
| In reply to | #3895 |
In article <iqips7$bta$1@dont-email.me>, Tobias Blass <tobiasblass@gmx.net> wrote: > On 2011-05-12, Keith Thompson <kst-u@mib.org> wrote: > > [snip] > > In some blatantly non-portable manner. > > > > There's probably some way to get the current "break" value as > > a void*. Given that value, you can add to it (by any of several > > methods) and pass the result to brk(). Or you can use sbrk(), which > > takes care of most of the bookkeeping for you. (Or, as the man > > page recommends rather strongly, use malloc() to allocate memory.) > > > If you call sbrk(0) it returns the current location of the > "program break", that is the end of the process's data segment. > Source: sbrk manpage Unless sbrk fails and returns an error. -- Damn the living - It's a lovely life. I'm whoever you want me to be. Silver silverware - Where is the love? At least I can stay in character. Oval swimming pool - Where is the love? Annoying Usenet one post at a time. Damn the living - It's a lovely life. In 1492....
[toc] | [prev] | [next] | [standalone]
| From | Seebs <usenet-nospam@seebs.net> |
|---|---|
| Date | 2011-05-13 08:36 +0000 |
| Message-ID | <slrnisprd4.2o58.usenet-nospam@guild.seebs.net> |
| In reply to | #3896 |
On 2011-05-13, Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> wrote: > Unless sbrk fails and returns an error. None of this changes that brk() is not an example of a function which is defined to, or expected to, take arbitrary integer values converted to pointers, or indeed, any integer values converted to pointers. -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions.
[toc] | [prev] | [next] | [standalone]
| From | "madamemandm@yahoo.com" <madamemandm@yahoo.com> |
|---|---|
| Date | 2011-05-13 07:08 -0700 |
| Message-ID | <5c5aadbb-268e-4542-94fe-966fbd3e592a@r33g2000prh.googlegroups.com> |
| In reply to | #3898 |
On May 13, 3:36 am, Seebs <usenet-nos...@seebs.net> wrote: > On 2011-05-13, Columbus sailed the ocean China Blue <chine.b...@yahoo.com> wrote: > > > Unless sbrk fails and returns an error. > > None of this changes that brk() is not an example of a function which > is defined to, or expected to, take arbitrary integer values converted > to pointers, or indeed, any integer values converted to pointers. Unfortunately, I can give an example. In the Windows API (it would have to be Windows), a number of functions that take constant strings can also take an ATOM. The definition of ATOM is typedef WORD ATOM; where WORD is a typedef for unsigned short. In particular, check the lpClassName parameter to CreateWindowEx. Martin Shobe
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-05-12 15:59 -0700 |
| Message-ID | <ln1v03jzjd.fsf@nuthaus.mib.org> |
| In reply to | #3847 |
Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> writes:
> In article <lniptfk4hl.fsf@nuthaus.mib.org>, Keith Thompson <kst-u@mib.org>
> wrote:
>
>> My current working hypothesis, given the lack of an actual
>> response, is that there are no such concrete examples, or at least
>> no significant ones, and that a C compiler that didn't support
>> converting arbitrary integer values to pointers without loss of
>> information wouldn't break much existing code.
>
> If you're finished digging yourself into a hole, you can start with
> man brk
>
> Otherwise feel free to dazzle your admirers with your inexperience.
Ok, I just checked the brk man page. On my system, it's declared as
int brk(void *addr);
There is no suggestion in the man page that the argument should be
anything other than an address; in particular, there's no hint that
passing some arbitrary integer value, converted to void*, would be
meaningful.
There's probably no way to construct a meaningful argument value while
staying within the bounds of behavior defined by the C standard, but
that's to be expected for such a low-level function.
I don't believe brk() is an example of what we were discussing.
For your reference, here's the question I asked you before:
Do you have a concrete example of an interface that expects
a void* argument, and depends on the ability to convert an
arbitrary integer value to a pointer without loss of information?
If you don't have such an example, "no" is a perfectly acceptable answer.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
Page 2 of 4 — ← Prev page 1 [2] 3 4 Next page →
Back to top | Article view | comp.lang.c
csiph-web